MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions
PeriodClock Class Reference

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 ()

## Detailed Description

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.

## Member Typedef Documentation

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.

## Constructor & Destructor Documentation

constexpr PeriodClock::PeriodClock | ( |  | ) |
| 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.

## Member Function Documentation

constexpr bool PeriodClock::Check | ( | Stamp | now,
|  | Duration | duration
| ) |  | const
| inline protected

Definition at line 59 of file PeriodClock.hxx.

bool PeriodClock::Check | ( | Duration | duration | ) | const
| inline

Checks whether the specified duration has passed since the last update.

Parameters

  duration | the duration

Definition at line 103 of file PeriodClock.hxx.

bool PeriodClock::CheckAlwaysUpdate | ( | Duration | duration | ) |
| inline

Checks whether the specified duration has passed since the last update.

After that, it updates the time stamp.

Parameters

  duration | the duration in milliseconds

Definition at line 143 of file PeriodClock.hxx.

bool PeriodClock::CheckUpdate | ( | Duration | duration | ) |
| inline

Checks whether the specified duration has passed since the last update.

If yes, it updates the time stamp.

Parameters

  duration | the duration in milliseconds

Definition at line 128 of file PeriodClock.hxx.

constexpr Delta PeriodClock::Elapsed | ( | Stamp | now | ) | const
| inline protected

Definition at line 53 of file PeriodClock.hxx.

Delta PeriodClock::Elapsed | ( |  | ) | const
| 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.

Delta PeriodClock::ElapsedUpdate | ( |  | ) |
| inline

Combines a call to Elapsed() and Update().

Definition at line 90 of file PeriodClock.hxx.

static Stamp PeriodClock::GetNow | ( |  | ) |
| inline static protected

Definition at line 49 of file PeriodClock.hxx.

constexpr bool PeriodClock::IsDefined | ( |  | ) | const
| inline

Definition at line 68 of file PeriodClock.hxx.

void PeriodClock::Reset | ( |  | ) |
| inline

Resets the clock.

Definition at line 75 of file PeriodClock.hxx.

void PeriodClock::Update | ( | Stamp | now | ) |
| inline protected

Definition at line 63 of file PeriodClock.hxx.

void PeriodClock::Update | ( |  | ) |
| inline

Updates the time stamp, setting it to the current clock.

Definition at line 110 of file PeriodClock.hxx.

void PeriodClock::UpdateWithOffset | ( | Delta | offset | ) |
| inline

Updates the time stamp, setting it to the current clock plus the specified offset.

Definition at line 118 of file PeriodClock.hxx.

The documentation for this class was generated from the following file:

- system/PeriodClock.hxx