Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
Public Member Functions | Static Public Member Functions | Friends | List of all members
CTimer Class Reference

Description

Timer class.

Definition at line 1582 of file base.H.

#include "base.H"

Inheritance diagram for CTimer:
Inheritance graph
[legend]

Public Member Functions

 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 Public Member Functions

static void DelByCreator (void *_creator)
 Remove all timers created by _creator from the event list.
 

Friends

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.
 

Member Function Documentation

◆ Set()

void CTimer::Set ( TTicks  _time,
TTicks  _interval = 0,
FTimerCallback _func = NULL,
void *  _data = NULL,
void *  _creator = NULL 
)

Setup and (re-)schedule timer.

Parameters
_timeMonotonic time of the next invocation. A value of 0 means "now". A value < 0 means "in `-_time` milliseconds from now".
_intervalRepeat interval. A value of <= 0 inserts a one-shot timer. This number should be a power of 2 (see note above).
_funcCallback function to be executed at the given times.
_dataData to be passed as the data argument to the callback function.
_creatorA 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()

bool CTimer::Pending ( )
inline

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: