Class Timer
#include <Timer.h >
Class to manage multiple timers, whether one-shot or periodic.
Unlike the Unix timer, this class provides app-provided callback data when each timer trigters.
This class is useful when you have multiple timed activities that need to happen at various times. When the time comes, the callback function is called.
It's also useful for event-driven programming where execution hangs off a select() statement.
Note: Only use one instance of this class. It claims the alarm() signal. If you use multiple instances, only the last instance invoked will be handled.
string label |
|
TimerCB cbfn |
|
void* cbdata |
|
time_t triggerTime |
|
int reloadSeconds |
*TimerCB TimerCB |
bool useAlarmSignals |
Default value: true |
bool serviceDuringSignal |
Default value: true |
Use Unix signaling to handle timer triggers unless instantiated with false
time_t triggerTime |
specific time when to call the callback function |
TimerCB cbfn |
callback function, e.g. void mycb(void * data) |
void* data |
callack data |
const string& triggerLabel |
label for managing this callback (app choice) |
Setup a one-time timer event.
Return value: true upon success, false upon failure
int seconds |
number of seconds in the future to run the callback function |
TimerCB cbfn |
callback function, e.g. void mycb(void * data) |
void* data |
callack data |
const string& triggerLabel |
label for managing this callback (app choice) |
Setup a time to trigger every so many seconds
Return value: true upon success, false upon failure
const string& triggerLabel |
label for the timer to cancel |
Cancel a timer that was setup
Return value: true upon success, false upon failure
time_t t |
time to use to find next event Default value: 0 |
int secondsTillEndOfTime |
Default value: TimerEndOfTime |
Countdown to next timer event (handy for select() call timeout)
If a time is provided, that is used as the current time
Return value: number of seconds till next event
const string& triggerLabel |
label for the timer to check |
time_t t |
time to use to find next event Default value: 0 |
int secondsTillEndOfTime |
Default value: TimerEndOfTime |
Countdown in seconds until the provided trigger label.
Return value: number of seconds till next event
time_t t |
time to use to find next event Default value: 0 |
Process any current or past due timer triggers
If a time is provided, that is used as the current time
Return value: number of events processed
Get the timer state of all configured timers - key: timer label; value: seconds till trigger
Return value: key/value pairs of timer labels and seconds until they fire
class TimerEntry label |