|
||
class CTimer : public CActive;
Base class for a timer active object.
This is an active object that uses the asynchronous services provided by RTimer
, to generate events. These events occur either at a specific time specified as a TTime
, or after an interval specified in microseconds.
The CActive::RunL()
virtual member function is called by the active scheduler after this event occurs.
To write a class derived from CTimer, first define and implement a constructor through which the priority of the CTimer active
object can be specified. Then define and implement a suitable CActive::RunL()
function to handle the completion of a timer request. This function is not defined by CTimer itself and must, therefore,
be provided by the derived class.
This class is ultimately implemented in terms of the nanokernel tick, and therefore the granularity of the generated events is limited to the period of this timer. This is variant specific, but is usually 1 millisecond.
Note that the CPeriodic
and CHeartbeat
classes are derived from CTimer, and answer most timing needs.
CBase
-
Base class for all classes to be instantiated on the heap.
CActive
-
The core class of the active object abstraction.
CTimer
-
Base class for a timer active object.
Defined in CTimer
:
After(TTimeIntervalMicroSeconds32)
Requests an event after an interval.At(const TTime &)
Requests an event at a given local time.AtUTC(const TTime &)
Requests an event at a given UTC time.CTimer(TInt)
Protected constructor with priority.ConstructL()
Constructs a new asynchronous timer.DoCancel()
Implements cancellation of an outstanding request.HighRes(TTimeIntervalMicroSeconds32)
Requests an event after the specified interval to a resolution of 1ms. The "...Inactivity(TTimeIntervalSeconds)
Requests an event if no activity occurs within the specified interval.Lock(TTimerLockSpec)
Requests an event on a specified second fraction.~CTimer()
Destructor.Inherited from CActive
:
CActive(TInt)
Constructs the active object with the specified priority.Cancel()
Cancels the wait for completion of an outstanding request.Deque()
Removes the active object from the active scheduler's list of active objects.EPriorityHigh
A priority higher than EPriorityUserInput.EPriorityIdle
A low priority, useful for active objects representing background processing.EPriorityLow
A priority higher than EPriorityIdle but lower than EPriorityStandard.EPriorityStandard
Most active objects will have this priority.EPriorityUserInput
A priority higher than EPriorityStandard; useful for active objects handling use...Extension_(TUint,TAny *&,TAny *)
Extension function IsActive()const
Determines whether the active object has a request outstanding.IsAdded()const
Determines whether the active object has been added to the active scheduler's li...Priority()const
Gets the priority of the active object.RunError(TInt)
Handles a leave occurring in the request completion event handler CActive::RunL(...RunL()
Handles an active object's request completion event.SetActive()
Indicates that the active object has issued a request and that it is now outstan...SetPriority(TInt)
Sets the priority of the active object.TPriority
Defines standard priorities for active objects. iStatus
The request status associated with an asynchronous request.Inherited from CBase
:
Delete(CBase *)
Deletes the specified object.operator new(TUint)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TAny *)
Initialises the object to binary zeroes.operator new(TUint,TLeave)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TLeave,TUint)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TUint)
Allocates the object from the heap and then initialises its contents to binary z...IMPORT_C ~CTimer();
Destructor.
Frees resources prior to destruction. Specifically, it cancels any outstanding request and closes the RTimer
handle.
protected: IMPORT_C CTimer(TInt aPriority);
Protected constructor with priority.
Use this constructor to set the priority of the active object.
Classes derived from CTimer must define and provide a constructor through which the priority of the active object can be passed. Such a constructor can call CTimer's constructor in its constructor initialisation list.
|
protected: IMPORT_C void ConstructL();
Constructs a new asynchronous timer.
The function must be called before any timer requests (i.e. calls to RTimer::After(TRequestStatus &,TTimeIntervalMicroSeconds32)
or RTimer::At(TRequestStatus &,const TTime &)
) can be made.
Since it is protected, it cannot be called directly by clients of CTimer derived classes. Typically, a derived class makes
a base call to this function in the second phase of two-phase construction; i.e. the derived class defines and implements
its own CTimer::ConstructL()
function within which it makes a base call to CTimer::ConstructL()
.
IMPORT_C void At(const TTime &aTime);
Requests an event at a given local time.
This timer completes at the specified time - if the machine is in a turned off state at that time, the machine will be turned on again.
Notes:
1. The CTimer' CActive::RunL()
function will be run as soon as possible after the specified system time.
2. The CActive::RunL()
may be delayed because the CActive::RunL()
of another active object, with the deepest nesting-level active scheduler on the same thread, is running when the event occurs:
this cannot be avoided, but can be minimised by making all CActive::RunL()
s of short duration.
3. The CActive::RunL()
may be delayed because other, higher-priority, active objects are scheduled instead. This can be avoided by making CTimers
very high-priority.
4. The TTime
object should be set to the home time.
|
TTime::HomeTime()
Sets the date and time of this TTime to the home time. IMPORT_C void AtUTC(const TTime &aTimeInUTC);
Requests an event at a given UTC time.
This timer completes at the specified time - if the machine is in a turned off state at that time, the machine will be turned on again.
Notes:
1. The CTimer' CActive::RunL()
function will be run as soon as possible after the specified system time.
2. The CActive::RunL()
may be delayed because the CActive::RunL()
of another active object, with the deepest nesting-level active scheduler on the same thread, is running when the event occurs:
this cannot be avoided, but can be minimised by making all CActive::RunL()
s of short duration.
3. The CActive::RunL()
may be delayed because other, higher-priority, active objects are scheduled instead. This can be avoided by making CTimers
very high-priority.
4. The TTime
object should be set to the universal time.
|
TTime::UniversalTime()
Sets the date and time of this TTime to the universal time. IMPORT_C void After(TTimeIntervalMicroSeconds32 anInterval);
Requests an event after an interval.
This timer completes after the specified number of microseconds. The "after timer" counter stops during power-down. Therefore, a 5-second timer will complete late if the machine is turned off 2 seconds after the request is made.
Notes:
1. The CTimer's CActive::RunL()
function will be run as soon as possible after the specified interval.
2. The CActive::RunL()
may be delayed because the CActive::RunL()
of another active object, with the deepest nesting-level active scheduler on the same thread, is running when the event occurs:
this cannot be avoided, but can be minimised by making all CActive::RunL()
s of short duration.
3. The CActive::RunL()
may be delayed because other, higher-priority, active objects are scheduled instead. This can be avoided by making CTimers
very high-priority.
|
|
IMPORT_C void Lock(TTimerLockSpec aLock);
Requests an event on a specified second fraction.
Note that the CActive::RunL()
function is run exactly on the specified second fraction.
|
IMPORT_C void Inactivity(TTimeIntervalSeconds aSeconds);
Requests an event if no activity occurs within the specified interval.
|
IMPORT_C void HighRes(TTimeIntervalMicroSeconds32 aInterval);
Requests an event after the specified interval to a resolution of 1ms. The "HighRes timer" counter stops during power-down (the same as "after timer").
|
|
protected: IMPORT_C virtual void DoCancel();
Implements cancellation of an outstanding request.
This function is called as part of the active object's CActive::Cancel()
.
It must call the appropriate cancel function offered by the active object's asynchronous service provider. The asynchronous service provider's cancel is expected to act immediately.
CTimer::DoCancel()
must not wait for event completion; this is handled by CActive::Cancel()
.
CActive::Cancel()
Cancels the wait for completion of an outstanding request.