CL_TimerManager::subscribe
Syntax
static bool subscribe(
int milliseconds,
CL_TimerCallback *callback_class,
float tolerance,
bool periodic,
bool delete_pointer = true);
Parameters
milliseconds | - | Specifies the callback granularity, eg. with what intervals the callback function should be called. |
callback_class | - | Must point to an instance of the CL_TimerCallback class, which is to be called with the given interval. |
tolerance | - | Denotes the callback tolerance relative to the callback granularity, eg. how important it is, that the callback be performed on time. 0 denotes zero tolerance, whereas 1 for instance means, that it's ok that the callback varies by as much as 1*'milliseconds' milliseconds. |
periodic | - | Boolean indicating whether this is a "one-shot" callback, which should be called once only, or it is a periodic callback, which should be called until a call to unsubscribe. |
delete_pointer | - | Indicates if the instanced callback class should be deleted upon program exit, or a call to unsubscribe. |
Return value
Returns whether the subscribtion attempt succeeded.
Description
Static function used to subscribe a new timer-class to the timer. Asks the timermanager to call callback_class->callback() every milliseconds millisecond, with a time-tolerance of tolerance measured relative to the interval. Milliseconds=20 and tolerance=0.5 eg. means that callback_class has to be called every 10-30-th millisecond. periodic indicates whether the callback_class should be called only once, or every millisecond millisecond, until unsubscribe is called. Pr. default the timermanager deletes the pointer to the callback_class when the manager is destroyed at program-termination-time, but if delete_pointer==false this won't happen - likewise, the callback_class gets deleted when unsubscribing.
Back to index
|