This class manages a Visualization Server timer that will call a callback function when it expires. More...
#include <ilserver/timer.h>
Public Member Functions | |
IlsTimer (const IlsString &id, int sec, int milli=0, IlsTimerCallback proc=0, IlsAny arg=0) | |
Builds a new timer and gives it an identifier. More... | |
IlsTimer (int sec, int milli=0, IlsTimerCallback proc=0, IlsAny arg=0) | |
Builds a new timer whose period is sec seconds and milli miliseconds. More... | |
IlsBoolean | autoDelete () const |
Returns IlsTrue or IlsFalse depending on whether or not the timer is in autoDelete mode. | |
void | autoDelete (IlsBoolean b) |
Updates the timer to mark it as "to be deleted", after having been fired, if the argument is IlsTrue , or not to be deleted if the argument is IlsFalse . | |
const IlsString & | getId () const |
Returns the identifier of the timer if one has been specified. | |
IlsBoolean | isRunning () const |
Returns IlsTrue if the timer is running. | |
IlsBoolean | runOnce () const |
Returns IlsTrue if the timer is set to be fired only once or IlsFalse if it is set to be fired periodically. | |
void | runOnce (IlsBoolean b) |
This member function updates the timer to be fired either only once if the Boolean argument is IlsTrue , or periodically if the argument is IlsFalse . More... | |
virtual void | start () |
Starts the timer. | |
virtual void | start (int sec, int milli=0) |
Starts the timer with a new time period. More... | |
void | stop () |
Stops a running timer. | |
Friends | |
class | IlsTimerManager |
This class manages a Visualization Server timer that will call a callback function when it expires.
Library: server
and mvcomp
Timers are managed by the Timer Manager, an instance of IlsTimerManager
. You can use timers both on the server side and on the client side. Timers can only be used with the multithread version of the Server library.
IlsTimerManager
. IlsTimer::IlsTimer | ( | int | sec, |
int | milli = 0 , |
||
IlsTimerCallback | proc = 0 , |
||
IlsAny | arg = 0 |
||
) |
Builds a new timer whose period is sec seconds and milli miliseconds.
When the timer is triggered, the proc callback is invoked with arg as the argument. The timer is not started when built. You must call the virtual member function start()
to start it.
You should instantiate timers on the heap using new
. It is your responsibility to delete the timers you create. If a timer is in autoDelete
mode and is designed to be triggered only once, it will be deleted by Visualization Server after it has been fired.
Long running callbacks can prevent other timers from firing.
Long running callbacks can prevent the application from exiting.
IlsTimer::IlsTimer | ( | const IlsString & | id, |
int | sec, | ||
int | milli = 0 , |
||
IlsTimerCallback | proc = 0 , |
||
IlsAny | arg = 0 |
||
) |
Builds a new timer and gives it an identifier.
id | identifier |
sec | seconds |
milli | milliseconds |
proc | callback |
arg | callback argument |
void IlsTimer::runOnce | ( | IlsBoolean | b | ) |
This member function updates the timer to be fired either only once if the Boolean argument is IlsTrue
, or periodically if the argument is IlsFalse
.
By default, a timer is fired only once.
|
virtual |
Starts the timer with a new time period.
sec | seconds |
milli | milliseconds |