|
|
Simple rate limiter for use in loops to maintain a certain frequency given a clock. More...
#include <ArmarXCore/core/time/Metronome.h>
Public Member Functions | |
| Metronome (const Duration &targetPeriod, ClockType clockType=ClockType::Virtual) | |
| Constructs a new rate limiter with given target period and clock type. More... | |
| Metronome (const Duration &targetPeriod, const Clock &clock) | |
| Constructs a new rate limiter with given target period and clock. More... | |
| Metronome (const Frequency &targetFrequency, ClockType clockType=ClockType::Virtual) | |
| void | reset () |
| Resets the rate limiter so that the next targetted time point will be in the current time plus the target period. More... | |
| Duration | waitForNextTick () |
| Wait and block until the target period is met. More... | |
Simple rate limiter for use in loops to maintain a certain frequency given a clock.
In most cases, it is enough sufficient to construct a rate limiter with a given target duration (or target period). This will then use virtual time. In cases where a specific clock is required, a constructor taking a clock or clock type can be used.
Code example:
Definition at line 34 of file Metronome.h.
| Metronome | ( | const Frequency & | targetFrequency, |
| ClockType | clockType = ClockType::Virtual |
||
| ) |
Definition at line 8 of file Metronome.cpp.
| Metronome | ( | const Duration & | targetPeriod, |
| ClockType | clockType = ClockType::Virtual |
||
| ) |
Constructs a new rate limiter with given target period and clock type.
| targetPeriod | Period to target for in loops etc. |
| clockType | Type of clock to use to assess time. |
Definition at line 14 of file Metronome.cpp.
Constructs a new rate limiter with given target period and clock.
| targetPeriod | Period to target for in loops etc. |
| clock | Clock to use to assess time. |
Definition at line 20 of file Metronome.cpp.
| void reset | ( | ) |
Resets the rate limiter so that the next targetted time point will be in the current time plus the target period.
Definition at line 35 of file Metronome.cpp.
Here is the call graph for this function:| Duration waitForNextTick | ( | ) |
Wait and block until the target period is met.
Definition at line 27 of file Metronome.cpp.
Here is the call graph for this function:
Here is the caller graph for this function: