Original Symbian headers
Selected EUSER, Window Server, networking, graphics and device declarations
Loading...
Searching...
No Matches
CTimer Class Reference

Base class for a timer active object. More...

#include <e32base.h>

Inheritance diagram for CTimer:
CActive CBase CHeartbeat CPeriodic

Public Member Functions

IMPORT_C ~CTimer ()
 Destructor.
 
IMPORT_C void At (const TTime &aTime)
 Requests an event at a given local time.
 
IMPORT_C void AtUTC (const TTime &aTimeInUTC)
 Requests an event at a given UTC time.
 
IMPORT_C void After (TTimeIntervalMicroSeconds32 anInterval)
 Requests an event after an interval.
 
IMPORT_C void Lock (TTimerLockSpec aLock)
 Requests an event on a 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.
 
- Public Member Functions inherited from CActive
IMPORT_C ~CActive ()
 Frees resources prior to destruction.
 
IMPORT_C void Cancel ()
 Cancels the wait for completion of an outstanding request.
 
IMPORT_C void Deque ()
 Removes the active object from the active scheduler's list of active objects.
 
IMPORT_C void SetPriority (TInt aPriority)
 Sets the priority of the active object.
 
TBool IsActive () const
 Determines whether the active object has a request outstanding.
 
TBool IsAdded () const
 Determines whether the active object has been added to the active scheduler's list of active objects.
 
TInt Priority () const
 Gets the priority of the active object.
 
- Public Member Functions inherited from CBase
 CBase ()
 Default constructor.
 
virtual IMPORT_C ~CBase ()
 Virtual destructor.
 
TAny * operator new (TUint aSize, TAny *aBase) __NO_THROW
 Initialises the object to binary zeroes.
 
TAny * operator new (TUint aSize) __NO_THROW
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 
TAny * operator new (TUint aSize, TLeave)
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 
TAny * operator new (TUint aSize, TUint aExtraSize) __NO_THROW
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 
TAny * operator new (TUint aSize, TLeave, TUint aExtraSize)
 Allocates the object from the heap and then initialises its contents to binary zeroes.
 

Protected Member Functions

IMPORT_C CTimer (TInt aPriority)
 Protected constructor with priority.
 
IMPORT_C void ConstructL ()
 Constructs a new asynchronous timer.
 
IMPORT_C void DoCancel ()
 Implements cancellation of an outstanding request.
 
- Protected Member Functions inherited from CActive
IMPORT_C CActive (TInt aPriority)
 Constructs the active object with the specified priority.
 
IMPORT_C void SetActive ()
 Indicates that the active object has issued a request and that it is now outstanding.
 
virtual void RunL ()=0
 Handles an active object's request completion event.
 
virtual IMPORT_C TInt RunError (TInt aError)
 Handles a leave occurring in the request completion event handler RunL().
 
virtual IMPORT_C TInt Extension_ (TUint aExtensionId, TAny *&a0, TAny *a1)
 Extension function.
 

Additional Inherited Members

- Public Types inherited from CActive
enum  TPriority {
  EPriorityIdle =-100 , EPriorityLow =-20 , EPriorityStandard =0 , EPriorityUserInput =10 ,
  EPriorityHigh =20
}
 Defines standard priorities for active objects. More...
 
- Static Public Member Functions inherited from CBase
static IMPORT_C void Delete (CBase *aPtr)
 Deletes the specified object.
 
- Public Attributes inherited from CActive
TRequestStatus iStatus
 The request status associated with an asynchronous request.
 

Detailed Description

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 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 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.

See also
CHeartbeat
CPeriodic
CHeartbeat
API status
Published to all clients. Released API.

Definition at line 2003 of file e32base.h.

Constructor & Destructor Documentation

◆ ~CTimer()

IMPORT_C CTimer::~CTimer ( )

Destructor.

Frees resources prior to destruction. Specifically, it cancels any outstanding request and closes the RTimer handle.

(generated from Symbian Developer Library)

◆ CTimer()

IMPORT_C CTimer::CTimer ( TInt  aPriority)
protected

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.

Parameters
aPriorityThe priority of the timer.

(generated from Symbian Developer Library)

Member Function Documentation

◆ After()

IMPORT_C void CTimer::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 RunL() function will be run as soon as possible after the specified interval.
  2. The RunL() may be delayed because the 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 RunL()s of short duration.
  3. The RunL() may be delayed because other, higher-priority, active objects are scheduled instead. This can be avoided by making CTimers very high-priority.
Parameters
anIntervalInterval after which event is to occur, in microseconds.

Panic condition: USER 87, if anInterval is negative. This is raised by the underlying RTimer.

Panic condition: E32USER-CBase 51, if the active object has not been added to an active scheduler.

(generated from Symbian Developer Library)

◆ At()

IMPORT_C void CTimer::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' RunL() function will be run as soon as possible after the specified system time.
  2. The RunL() may be delayed because the 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 RunL()s of short duration.
  3. The 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

Parameters
aTimeThe local time at which the event is to occur.

(generated from Symbian Developer Library)

◆ AtUTC()

IMPORT_C void CTimer::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' RunL() function will be run as soon as possible after the specified system time.
  2. The RunL() may be delayed because the 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 RunL()s of short duration.
  3. The 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

(generated from Symbian Developer Library)

◆ ConstructL()

IMPORT_C void CTimer::ConstructL ( )
protected

Constructs a new asynchronous timer.

The function must be called before any timer requests (i.e. calls to RTimer::After() or RTimer::At()) 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 ConstructL() function within which it makes a base call to CTimer::ConstructL().

(generated from Symbian Developer Library)

◆ DoCancel()

IMPORT_C void CTimer::DoCancel ( )
protectedvirtual

Implements cancellation of an outstanding request.

This function is called as part of the active object's 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.

DoCancel() must not wait for event completion; this is handled by Cancel().

See also
CActive::Cancel

Implements CActive.

◆ HighRes()

IMPORT_C void CTimer::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").

Parameters
aIntervalThe time interval, in microseconds, after which an event is to occur.

Panic condition: USER 87, if anInterval is negative. This is raised by the underlying RTimer.

Panic condition: KERN-EXEC 15, if this function is called while a request for a timer event is still outstanding.

(generated from Symbian Developer Library)

◆ Inactivity()

IMPORT_C void CTimer::Inactivity ( TTimeIntervalSeconds  aSeconds)

Requests an event if no activity occurs within the specified interval.

Parameters
aSecondsThe time interval.

(generated from Symbian Developer Library)

◆ Lock()

IMPORT_C void CTimer::Lock ( TTimerLockSpec  aLock)

Requests an event on a specified second fraction.

Note that the RunL() function is run exactly on the specified second fraction.

Parameters
aLockThe fraction of a second at which the timer completes.

(generated from Symbian Developer Library)


The documentation for this class was generated from the following files: