20 #ifndef MPD_PERIOD_CLOCK_HXX 21 #define MPD_PERIOD_CLOCK_HXX 31 typedef std::chrono::steady_clock::duration
Duration;
33 typedef std::chrono::steady_clock::time_point
Stamp;
50 return std::chrono::steady_clock::now();
54 return last ==
Stamp()
60 return now >= last + duration;
69 return last >
Stamp();
92 const auto result =
Elapsed(now);
130 if (
Check(now, duration)) {
145 bool ret =
Check(now, duration);
constexpr bool Check(Stamp now, Duration duration) const
constexpr PeriodClock()
Initializes the object, setting the last time stamp to "0", i.e.
Delta Elapsed() const
Returns the time elapsed since the last update().
bool CheckUpdate(Duration duration)
Checks whether the specified duration has passed since the last update.
std::chrono::steady_clock::duration Duration
bool Check(Duration duration) const
Checks whether the specified duration has passed since the last update.
std::chrono::steady_clock::time_point Stamp
void Update()
Updates the time stamp, setting it to the current clock.
Delta ElapsedUpdate()
Combines a call to Elapsed() and Update().
constexpr bool IsDefined() const
void Reset()
Resets the clock.
bool CheckAlwaysUpdate(Duration duration)
Checks whether the specified duration has passed since the last update.
This is a stopwatch which saves the timestamp of an event, and can check whether a specified time spa...
void UpdateWithOffset(Delta offset)
Updates the time stamp, setting it to the current clock plus the specified offset.
constexpr Delta Elapsed(Stamp now) const