Timer class.
Definition at line 1582 of file base.H.
#include "base.H"
|
| CTimer (FTimerCallback *_func, void *_data=NULL, void *_creator=NULL) |
| Construct with a callback function.
|
|
| CTimer (TTicks _time, TTicks _interval=0, FTimerCallback *_func=NULL, void *_data=NULL, void *_creator=NULL) |
| Construct with a time/interval specification and eventually a callback function.
|
|
void | Set (FTimerCallback *_func, void *_data=NULL, void *_creator=NULL) |
| Setup timer without (re-)scheduling it.
|
|
void | Set (TTicks _time, TTicks _interval=0, FTimerCallback *_func=NULL, void *_data=NULL, void *_creator=NULL) |
| Setup and (re-)schedule timer. More...
|
|
void | Reschedule (TTicks _time, TTicks _interval=0) |
| Change a timer (like 'Set'), but leave function and creator unchanged.
|
|
void | Clear () |
| Remove timer from the event list.
|
|
bool | Pending () |
| Indicate whether the timer is pending and may be executed in the future. More...
|
|
virtual void | OnTime () |
| [T:timer] Virtual function called when the timer triggers.
|
|
|
static void | DelByCreator (void *_creator) |
| Remove all timers created by _creator from the event list.
|
|
|
bool | TimerIterate () |
| Returns false if nothing was done.
|
|
TTicks | TimerGetDelay () |
| Returns number of milliseconds until next call to TimerIterate() is necessary, or -1 if no timer is pending.
|
|
◆ Set()
void CTimer::Set |
( |
TTicks |
_time, |
|
|
TTicks |
_interval = 0 , |
|
|
FTimerCallback * |
_func = NULL , |
|
|
void * |
_data = NULL , |
|
|
void * |
_creator = NULL |
|
) |
| |
Setup and (re-)schedule timer.
- Parameters
-
_time | Monotonic time of the next invocation. A value of 0 means "now". A value < 0 means "in `-_time` milliseconds from now". |
_interval | Repeat interval. A value of <= 0 inserts a one-shot timer. This number should be a power of 2 (see note above). |
_func | Callback function to be executed at the given times. |
_data | Data to be passed as the data argument to the callback function. |
_creator | A reference to the creator. If set (!= NULL ), the class takes over the ownership. of this object. In consequence, the caller does not need to keep a reference to this object, but can eventually remove all of them using DelByCreator() . |
◆ Pending()
Indicate whether the timer is pending and may be executed in the future.
**Note:** Be careful with potential race conditions. A value of 'false' can be safely be
used to draw conclusions, given that only the calling thread may call 'Set' & friends.
A value of 'true' may change to 'false' at any time.
Definition at line 1611 of file base.H.
The documentation for this class was generated from the following file: