class smTimer

Class that implements a Shlaer-Mellor timer event

Public Classes

enum
We measure time in seconds starting from eSecOffset to get readable numbers ( don not care about Jan 1970!)

Public Methods

static void cancel( smTimer *pTimer )
Deletes the timer by calling its destructor
void fire()
Fires the timer
static int FireTimers()
Loop over all timer and fire the ones that have been expired
inline int getTimeRemaining()
Returns the time in milliseconds until the timer fires
static void listAll( ostream &os = cout )
Calls identify on all timers
smTimer( int nMilliSec, rcEvent *pEvent )
Constructor with the argument of the timeout value (number of milliseconds to wait) and the event that will be generated if the timout occurs
~smTimer()
Deletes the timer

Public

enum
We measure time in seconds starting from eSecOffset to get readable numbers ( don not care about Jan 1970!)

Private Fields

bool bFired
If true, the timer has been fired
static bool bPrintOnFire
If true, print a message when the timer fires
static multimap <int, smTimer*, less<int> > mapTimers
STL multimap that holds all active timers ordered by their timeout
rcEvent* pEvent
Run control event that will be send to the event queue when the timer fires
int tFire
Time when the timer will be fired

Private Methods

static int getTime()
Calculates the current time

Documentation

Class that implements a Shlaer-Mellor timer event. Timer events are used to avoid a deadlock, which can occur when an object waits for an event that never arrives. For example the run control sends an event to a DCM, but the DCM server has crashed and therefore no reply is ever sent back to the run control.
Timer events have a run control event internally and a timeout value. When the timeout has occured, the timer event is fired, which means that the internal run control event is sent (i.e. put on the rcEventQueue deque). It is noteworthy that the timer event is always put at the beginning of the deque.
Timer events can also be cancelled, which has to be done, when the object that generated the timer receives the desired event and therefore no timeout can occur.

The timers are organized in an STL multimap with the timeout value as the key (first parameter of the multimap).

See also: rcEvent, rcEventQueue

enum
We measure time in seconds starting from eSecOffset to get readable numbers ( don not care about Jan 1970!)

smTimer( int nMilliSec, rcEvent *pEvent )
Constructor with the argument of the timeout value (number of milliseconds to wait) and the event that will be generated if the timout occurs

~smTimer()
Deletes the timer. It deletes the object and removes the entry from the multimap of timers.

void fire()
Fires the timer. This means that the timer object is put to the from the rcEventQueue (which is implemented as a deque, such that one can add elements at the beginning and the end).

static int FireTimers()
Loop over all timer and fire the ones that have been expired

static void cancel( smTimer *pTimer )
Deletes the timer by calling its destructor

inline int getTimeRemaining()
Returns the time in milliseconds until the timer fires

static void listAll( ostream &os = cout )
Calls identify on all timers

static multimap <int, smTimer*, less<int> > mapTimers
STL multimap that holds all active timers ordered by their timeout

static int getTime()
Calculates the current time. Timer events are created by saying how long one has to wait until the event occurs (unless it is cancelled). We use CLOCK_REALTIME but want to use an offset, such that we get smaller values.

static bool bPrintOnFire
If true, print a message when the timer fires

bool bFired
If true, the timer has been fired

int tFire
Time when the timer will be fired

rcEvent* pEvent
Run control event that will be send to the event queue when the timer fires


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de