class MultiTimerThread

Multi Timer Thread. More...

Contains pure virtuals
Full nameCoral::MultiTimerThread
Definition#include <multitimerthread.h>
Template formMultiTimerThread<const cardinal Timers>
InheritsCoral::Thread [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods


Detailed Description

This abstract class realizes a timer thread with multiple timers, based on Thread. The user of this class has to implement timerEvent(). Inaccurate system timers are corrected by calling user's timerEvent() implementation multiple times if necessary. This feature can be modified by setTimerCorrection (Default is on at a maximum of 10 calls).

See also: Thread

 MultiTimerThread (const char* name = "MultiTimerThread", const cardinal flags = TF_CancelDeferred)

MultiTimerThread

Constructor. A new multitimer thread with a given interval will be created but *not* started! To start the new thread, call start(). The interval gives the time for the interval in microseconds, the virtual function timerEvent() is called. The default timer correction is set to 10. See setTimerCorrection() for more information on timer correction. The first call of timerEvent() will be made immediately, if the fast start option is set (default). Otherwise it will be made after the given interval.

Parameters:
usecInterval in microseconds.
nameThread name.
flagsThread flags.

See also: Thread#start, timerEvent, Thread#Thread, setTimerCorrection, setFastStart

 ~MultiTimerThread ()

~MultiTimerThread

Destructor.

inline card64  getInterval (const cardinal timer)

getInterval

[const]

Get timer interval.

Parameters:
timerTimer number.

Returns: Interval in microseconds.

inline void  setInterval (const cardinal timer, const card64 usec, const card64 callLimit = 0)

setInterval

Set timer interval. Note, that the first timerEvent() call will be immediately, is FastStart mode is set, see also setFastStart(). For single shot timers, you probably have to call setFastStart(nr,0) first!

Parameters:
timerTimer number.
usecInterval in microseconds (0 to deactivate timer).
callLimitCall count limit (0 for infinite).

See also: setFastStart

inline void  setNextAction (const cardinal timer, const card64 usec = 0, const card64 callLimit = 1)

setNextAction

Like setInterval(), but disabling FastStart first. This method can be used e.g. for single shot timers.

Parameters:
timerTimer number.
usecTime to next invokation (0 = immediately).
callLimitCall count limit (0 for infinite, default: 1).

See also: setInterval

inline void  setNextActionAbs (const cardinal timer, const card64 timeStamp = 0, const card64 callLimit = 1)

setNextActionAbs

Like setNextAction(), but the time stamp of the next invokation is given as absolute time (microseconds since January 01, 1970).

Parameters:
timerTimer number.
usecTime to next invokation (0 = immediately).
callLimitCall count limit (0 for infinite, default: 1).

See also: setInterval, setNextAction

inline cardinal  getTimerCorrection (const cardinal timer)

getTimerCorrection

[const]

Get maximum correction value for inaccurate system timer.

Parameters:
timerTimer number.

Returns: true, if activated; false if not.

See also: setTimerCorrection

inline void  setTimerCorrection (const cardinal timer, const cardinal maxCorrection = 0)

setTimerCorrection

Set correction of inaccurate system timer to given value. This on will cause the timerEvent() function to be called a maximum of maxCorrection times, if the total number of calls is lower than the calculated number of times the function should have been called. If the number of correction calls is higher than maxCorrection, *no* correction will be done! Default is 0, which turns correction off.

Parameters:
timerTimer number.
oftrue to activate correction; false to deactivate.

inline void  leaveCorrectionLoop (const cardinal timer)

leaveCorrectionLoop

Leave timer correction loop: If the thread is in a timer correction loop, the loop will be finished after the current timerEvent() call returns.

Parameters:
timerTimer number.

inline void  setFastStart (const cardinal timer, const bool on)

setFastStart

Set fast start option: If false, the first call of timerEvent() will be made *after* the given interval; otherwise it will be made immediately. The default is true.

Parameters:
timerTimer number.
ontrue, to set option; false otherwise.

inline bool  getFastStart (const cardinal timer)

getFastStart

[const]

Get fast start option: If false, the first call of timerEvent() will be made *after* the given interval; otherwise it will be made immediately.

Parameters:
timerTimer number.

Returns: true, if option is set; false otherwise.

void  cancel ()

cancel

Reimplementation of Thread's cancel() method.

See also: Thread#cancel

Reimplemented from Thread.

void*  stop ()

stop

Reimplementation of Thread's stop() method.

See also: Thread#stop

Reimplemented from Thread.

void  timerEvent (const cardinal timer)

timerEvent

[protected pure virtual]

The virtual timerEvent() method, which contains the multitimer thread's implementation. It has to be implemented by classes, which inherit MultiTimerThread. This method is called regularly with the given interval.