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();
53 constexpr Delta
Elapsed(Stamp now)
const {
54 return last ==
Stamp()
59 constexpr
bool Check(Stamp now, Duration duration)
const {
60 return now >= last + duration;
69 return last >
Stamp();
92 const auto result =
Elapsed(now);
103 bool Check(Duration duration)
const {
130 if (
Check(now, duration)) {
145 bool ret =
Check(now, duration);
constexpr PeriodClock()
Initializes the object, setting the last time stamp to "0", i.e.
bool CheckUpdate(Duration duration)
Checks whether the specified duration has passed since the last update.
std::chrono::steady_clock::duration Duration
std::chrono::steady_clock::time_point Stamp
bool Check(Duration duration) const
Checks whether the specified duration has passed since the last update.
void Update()
Updates the time stamp, setting it to the current clock.
Delta Elapsed() const
Returns the time elapsed since the last update().
Delta ElapsedUpdate()
Combines a call to Elapsed() and Update().
constexpr bool Check(Stamp now, Duration duration) 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...
constexpr Delta Elapsed(Stamp now) const
void UpdateWithOffset(Delta offset)
Updates the time stamp, setting it to the current clock plus the specified offset.
constexpr bool IsDefined() const