|
Avara3D 0.2.0
C++ API reference
|
Invokes a callback at fixed intervals along a caller-supplied time line. More...
#include <a3d/util/PeriodicTrigger.h>
Public Member Functions | |
| PeriodicTrigger (std::chrono::duration< double > interval, bool deferFirstFire=false) | |
Creates a trigger with interval between firings. More... | |
| template<typename Function > | |
| std::size_t | update (double time, Function &&function) |
Advances the trigger to time and invokes function once for each due firing. More... | |
| void | reset () noexcept |
| Clears timing history so the next update establishes a new schedule. More... | |
Invokes a callback at fixed intervals along a caller-supplied time line.
update() catches up missed intervals by invoking the callback once for every elapsed trigger time. Supplying a time earlier than the previous update resets the schedule automatically.
Definition at line 26 of file PeriodicTrigger.h.
|
explicit |
Creates a trigger with interval between firings.
By default, the first update fires immediately. When deferFirstFire is true, the first firing is scheduled one interval after the first update time.
| std::invalid_argument | if interval is less than or equal to zero. |
|
noexcept |
Clears timing history so the next update establishes a new schedule.
|
inline |
Advances the trigger to time and invokes function once for each due firing.
| time | Current caller-defined time in seconds. |
| function | Callable invoked for every due interval. |
Definition at line 51 of file PeriodicTrigger.h.