MPD
0.20.18
|
This is a stopwatch which saves the timestamp of an event, and can check whether a specified time span has passed since then. More...
#include <PeriodClock.hxx>
Public Types | |
typedef std::chrono::steady_clock::duration | Duration |
typedef Duration | Delta |
typedef std::chrono::steady_clock::time_point | Stamp |
Public Member Functions | |
constexpr | PeriodClock () |
Initializes the object, setting the last time stamp to "0", i.e. More... | |
constexpr bool | IsDefined () const |
void | Reset () |
Resets the clock. More... | |
Delta | Elapsed () const |
Returns the time elapsed since the last update(). More... | |
Delta | ElapsedUpdate () |
Combines a call to Elapsed() and Update(). More... | |
bool | Check (Duration duration) const |
Checks whether the specified duration has passed since the last update. More... | |
void | Update () |
Updates the time stamp, setting it to the current clock. More... | |
void | UpdateWithOffset (Delta offset) |
Updates the time stamp, setting it to the current clock plus the specified offset. More... | |
bool | CheckUpdate (Duration duration) |
Checks whether the specified duration has passed since the last update. More... | |
bool | CheckAlwaysUpdate (Duration duration) |
Checks whether the specified duration has passed since the last update. More... | |
Protected Member Functions | |
constexpr Delta | Elapsed (Stamp now) const |
constexpr bool | Check (Stamp now, Duration duration) const |
void | Update (Stamp now) |
Static Protected Member Functions | |
static Stamp | GetNow () |
This is a stopwatch which saves the timestamp of an event, and can check whether a specified time span has passed since then.
Definition at line 29 of file PeriodClock.hxx.
typedef Duration PeriodClock::Delta |
Definition at line 32 of file PeriodClock.hxx.
typedef std::chrono::steady_clock::duration PeriodClock::Duration |
Definition at line 31 of file PeriodClock.hxx.
typedef std::chrono::steady_clock::time_point PeriodClock::Stamp |
Definition at line 33 of file PeriodClock.hxx.
|
inline |
Initializes the object, setting the last time stamp to "0", i.e.
a Check() will always succeed. If you do not want this default behaviour, call Update() immediately after creating the object.
Definition at line 46 of file PeriodClock.hxx.
Definition at line 59 of file PeriodClock.hxx.
|
inline |
Checks whether the specified duration has passed since the last update.
duration | the duration |
Definition at line 103 of file PeriodClock.hxx.
|
inline |
Checks whether the specified duration has passed since the last update.
After that, it updates the time stamp.
duration | the duration in milliseconds |
Definition at line 143 of file PeriodClock.hxx.
|
inline |
Checks whether the specified duration has passed since the last update.
If yes, it updates the time stamp.
duration | the duration in milliseconds |
Definition at line 128 of file PeriodClock.hxx.
Definition at line 53 of file PeriodClock.hxx.
|
inline |
Returns the time elapsed since the last update().
Returns a negative value if update() was never called.
Definition at line 83 of file PeriodClock.hxx.
|
inline |
Combines a call to Elapsed() and Update().
Definition at line 90 of file PeriodClock.hxx.
|
inlinestaticprotected |
Definition at line 49 of file PeriodClock.hxx.
|
inline |
Definition at line 68 of file PeriodClock.hxx.
|
inline |
Resets the clock.
Definition at line 75 of file PeriodClock.hxx.
|
inlineprotected |
Definition at line 63 of file PeriodClock.hxx.
|
inline |
Updates the time stamp, setting it to the current clock.
Definition at line 110 of file PeriodClock.hxx.
|
inline |
Updates the time stamp, setting it to the current clock plus the specified offset.
Definition at line 118 of file PeriodClock.hxx.