21template <
typename TTimerType>
24 using TPeriod =
typename TTimerType::TPeriod;
25 using TElapsed =
typename TTimerType::TElapsed;
26 using TStorage =
typename TTimerType::TStorage;
75template <
typename TTimerType>
78 using TPeriod =
typename TTimerType::TPeriod;
79 using TElapsed =
typename TTimerType::TElapsed;
87 [[nodiscard]]
IntervalTimer(
const TPeriod interval, std::function<
void(uint)> callback) :
106 std::function<void(uint)> callback;
115template <
typename TTimerType>
118 using TPeriod =
typename TTimerType::TPeriod;
119 using TElapsed =
typename TTimerType::TElapsed;
130 [[nodiscard]]
TimeoutTimer(
const TPeriod timeout, std::function<
void()> callback,
bool start =
false) :
181 std::function<void()> callback;
The base where every other type of timer is derived from.
TStorage storage
The storage of the timer.
virtual void Elapsed(TElapsed delta)=0
Called by the timer manager to notify the timer that the given amount of time has elapsed.
BaseTimer(const TPeriod period)
Create a new timer.
TPeriod period
The period of the timer.
virtual ~BaseTimer()
Delete the timer.
An interval timer will fire every interval, and will continue to fire until it is deleted.
void Elapsed(TElapsed count) override
Called by the timer manager to notify the timer that the given amount of time has elapsed.
void SetInterval(const TPeriod interval, bool reset=true)
Set a new interval for the timer.
IntervalTimer(const TPeriod interval, std::function< void(uint)> callback)
Create a new interval timer.
A timeout timer will fire once after the interval.
void Reset()
Reset the timer, so it will fire again after the timeout.
bool HasFired() const
Check whether the timeout occurred.
bool fired
Whether the timeout has occurred.
TimeoutTimer(const TPeriod timeout, std::function< void()> callback, bool start=false)
Create a new timeout timer.
void Elapsed(TElapsed count) override
Called by the timer manager to notify the timer that the given amount of time has elapsed.
void Abort()
Abort the timer so it doesn't fire if it hasn't yet.
void Reset(const TPeriod timeout)
Reset the timer, so it will fire again after the timeout.
The TimerManager manages a single Timer-type.
static void UnregisterTimer(BaseTimer< TTimerType > &timer)
Unregister a timer.
static void RegisterTimer(BaseTimer< TTimerType > &timer)
Register a timer.
static void ChangeRegisteredTimerPeriod(BaseTimer< TTimerType > &timer, TPeriod new_period)
Change the period of a registered timer.
Definition of the TimerManager.