Public Member Functions | |
long | schedule (in TimeoutHandler handler, in Epoch start, in Duration period) raises (ACSTimeError::ArgErrorEx) |
void | cancel (in long id) raises (ACSTimeError::InvalidIDEx) |
An interface designed to schedule timeouts for TimeoutHandler instances.
void acstime::Timer::cancel | ( | in long | id | ) | raises (ACSTimeError::InvalidIDEx) |
Cancels scheduled timeout(s).
id | identifier returned by schedule() |
long acstime::Timer::schedule | ( | in TimeoutHandler | handler, | |
in Epoch | start, | |||
in Duration | period | |||
) | raises (ACSTimeError::ArgErrorEx) |
Schedules timeout(s). When a timeout occurs, the handleTimeout() method of TimeoutHandler is called.
There are two types of timeouts:
For one shot timers, it is not necessary to call the cancel() method of this interface unless it is desired to cancel the timeout before it occurs. Continuous timeouts will continue to occur until cancel() is called to stop them.
Here is how timeouts are used: The client creates a TimeoutHandler object and passes its reference to schedule() along with start and period. The client must then call ci.run(), i.e. go to sleep. All the work is done in the handleTimeout() method of TimeoutHandler (that is called on each timeout). The client must sleep because there is only one thread on the client-side and it is used to call the TimeoutHandler's handleTimeout() method. This is assuming the usage of a C++ SimpleClient of course. If the "client" just happens to be a component, the sleep is unnecessary.
handler | a TimeoutHandler object reference | |
start | epoch at which first timeout is to occur, 0 => use current time plus period | |
period | period at which timeouts are to occur after first, 0 => only first timeout will occur so long as the start time is not also 0 |