OMTimerManager class

OMTimerManager provides timer services for all threads using a single timer task. The class is declared in the header file timer.h.

OMTimerManager manages timeout requests and issues timeout events to the system objects. OMTimerManager is a singleton active object. During framework initialization, the singleton is created and a single new thread is created for managing the timeout requests.

Note: In every application generated by Rational® Rhapsody®, a separate thread provides timer support for the application. If your application is single-threaded, the Rational Rhapsody-generated application will have two threads - one thread for the application and one thread for timer support.

OMThreadTimer inherits from OMTimerManager and performs the actual timing services for the framework and your application. For more information on OMThreadTimer, see OMThreadTimer class.

OMTimerManager can implement two time models:

Simulated time is useful for debugging and algorithm validation.

The simulated time support is in run-time (a parameter is provided to the framework in the application initialization). However, in order to switch between real and simulated time, you need to regenerate and build the code.

In the current version, simulated time is handled at initialization time, via the isRealTime parameter in OXF::init.

The following methods are used with simulated time mode: init, the OMTimerManagerDefaults class, goNext (private), and goNextAndPost.

Attribute summary
overflowMark - specifies the value used to determine whether the current system time has "overflowed"
Construction summary
OMTimerManager - constructs an OMTimerManager object
~OMTimerManager
Destroys the OMTimerManager object
Method summary
action - sends a matured timeout request to the relevant thread, where it is then inserted into the thread's event queue
cbkBridge
Is a bridge to get an interrupt from the operating system via the timeTickCbk (private) method
clearInstance
Cleans up the singleton instance of the timer manager
consumeTime
Is used in simulated time mode to simulate time consumption
destroyTimer
Cleans up the timer manager singleton instance
getElapsedTime
Returns the value of m_Time, the current system time.
goNextAndPost
Is used in simulated time mode
init
Starts the timer ticking
initInstance
Initializes the singleton instance
instance
Creates the singleton instance of the timer manager
resume
Is used by the framework to resume the timer during animation
set
Delegates a timeout request to OMTimerManager
setElapsedTime
Sets the value of m_Time, the current system time
softUnschedTm
Removes a specific timeout from the matured list
suspend
Is used by the framework to suspend the timer during animation
unschedTm
Cancels a timeout request

Attributes

overflowMark

This protected attribute specifies the value used to determine whether the current system time (m_Time) has "overflowed." m_Time is implemented as an unsigned long integer; its maximum value is implementation-dependent.

It is defined as follows:

RP_FRAMEWORK_DLL static const timeUnit
        overflowMark;

The timeUnit method is defined in rawtypes.h as follows:

typedef unsigned long timeUnit;

The value for overflowMark is specified in timer.cpp as follows:

const timeUnit OMTimerManager::overflowMark =
        0x80000000;

The post method compares m_Time to overflowMark after it gets a pointer to the current timeout request in the heap. If m_Time >= overflowMark, the post method iterates over the heap to adjust the dueTime of each timeout request, and resets m_Time as follows:

m_Time &= ~overflowMark;

Updating dueTime and m_Time uses system resources. You should monitor m_Time carefully for your application.


Feedback