blip  0.1
TimerManager Class Reference

A class that manages Timers and schedules TimerEvents for delivery when Timers fire. More...

#include <TimerManager.hpp>

Inheritance diagram for TimerManager:

Public Member Functions

 ~TimerManager ()
 Destructor. More...
 
TimerID addTimer (timespan_s_t interval, bool repeating=true)
 Add a new timer. More...
 
void cancelTimer (TimerID id)
 Cancel the timer with the given ID. More...
 
void cancelAllTimers ()
 Cancel all active timers. More...
 
uint_t getFreeTimerCount () const
 Get the number of available (inactive) timers. More...
 

Static Public Attributes

static const int MAX_TIMERS = 32
 The maximum number of timers that can be allocated by an application. More...
 

Detailed Description

A class that manages Timers and schedules TimerEvents for delivery when Timers fire.

At most TimerManager::MAX_TIMERS timers can be active per application. The TimerManager runs in its own dedicated thread; it is is threadsafe and can be safely used by multiple concurrent threads.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ ~TimerManager()

Destructor.

Member Function Documentation

◆ addTimer()

TimerID addTimer ( timespan_s_t  interval,
bool  repeating = true 
)

Add a new timer.

Parameters
intervalThe time interval at which this timer will fire, in seconds. If interval is 0, it is defaulted to 1.
repeatingA flag indicating whether this is a repeating or one-shot timer. A one-shot timer will be automatically cancelled after the first time it fires.
Returns
The ID of the new timer.
Exceptions
ResourceExhaustedExceptionIf all timers are already allocated.

◆ cancelAllTimers()

void cancelAllTimers ( )

Cancel all active timers.

◆ cancelTimer()

void cancelTimer ( TimerID  id)

Cancel the timer with the given ID.

Parameters
idThe timer ID.

◆ getFreeTimerCount()

uint_t getFreeTimerCount ( ) const

Get the number of available (inactive) timers.

Member Data Documentation

◆ MAX_TIMERS

const int MAX_TIMERS = 32
static

The maximum number of timers that can be allocated by an application.


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