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

Heatbeat timer. More...

#include <e32base.h>

Inheritance diagram for CHeartbeat:
CTimer CActive CBase

Public Member Functions

IMPORT_C ~CHeartbeat ()
 Destructor.
 
IMPORT_C void Start (TTimerLockSpec aLock, MBeating *aBeating)
 Starts generating heartbeat events.
 
- Public Member Functions inherited from CTimer
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.
 

Static Public Member Functions

static IMPORT_C CHeartbeat * New (TInt aPriority)
 Allocates and constructs a CHeartbeat object - non-leaving.
 
static IMPORT_C CHeartbeat * NewL (TInt aPriority)
 Allocates and constructs a CHeartbeat object - leaving.
 
- Static Public Member Functions inherited from CBase
static IMPORT_C void Delete (CBase *aPtr)
 Deletes the specified object.
 

Protected Member Functions

IMPORT_C CHeartbeat (TInt aPriority)
 Protected constructor with a priority.
 
IMPORT_C void RunL ()
 Handles an active object's request completion event.
 
- Protected Member Functions inherited from CTimer
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 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...
 
- Public Attributes inherited from CActive
TRequestStatus iStatus
 The request status associated with an asynchronous request.
 

Detailed Description

Heatbeat timer.

This class generates regular heartbeat events on a fixed fraction of a second. It is more accurate than a CPeriodic timer, because it provides a function to restore timer accuracy if it gets out of synchronisation with the system clock.

The protected RunL() function is called when the timer completes. The RunL() function in turn calls either the MBeating::Beat() or the MBeating::Synchronize() functions; MBeating is specified as a parameter to the Start() function used to start the heartbeat timer.

The relevant MBeating function may not be called immediately after the signal from the timer request has been generated, for the following reasons:

  1. the RunL() of another active object may be running at the time of the signal
  2. other active objects may have a higher priority than the CHeartbeat

If no heartbeat is missed, then the Beat() function is called.

If one or more heartbeats are missed then the Synchronize() function is called. It is important to bear in mind that the machine might be switched off after a few beats of the heart, and then Synchronize() will be called several days later. It is therefore essential that synchronisation is achieved as quickly as possible, rather than trying to catch up a tick at a time. In the context of an analogue clock, for instance, the clock should just redraw itself with the current time - rather than moving the hands round in steps until the time is correct.

CHeartbeat is an active object, derived from CActive (via CTimer). You should be familiar with CActive in order to understand CHeartbeat behaviour, but not necessarily with CTimer.

See also
MBeating
API status
Published to all clients. Released API.

Definition at line 2156 of file e32base.h.

Constructor & Destructor Documentation

◆ ~CHeartbeat()

IMPORT_C CHeartbeat::~CHeartbeat ( )

Destructor.

Frees resources prior to destruction.

(generated from Symbian Developer Library)

◆ CHeartbeat()

IMPORT_C CHeartbeat::CHeartbeat ( TInt  aPriority)
protected

Protected constructor with a priority.

Use this constructor to set the priority of the active object.

Classes derived from CHeartbeat must define and provide a constructor through which the priority of the active object can be passed. Such a constructor can call CHeartbeat's constructor in its constructor initialisation list.

Parameters
aPriorityThe priority of the timer.

(generated from Symbian Developer Library)

Member Function Documentation

◆ New()

static IMPORT_C CHeartbeat * CHeartbeat::New ( TInt  aPriority)
static

Allocates and constructs a CHeartbeat object - non-leaving.

Specify a high priority so the callback function is scheduled as soon as possible after the timer events complete.

Parameters
aPriorityThe priority of the active object. If timing is critical, it should be higher than that of all other active objects owned by the scheduler.

(generated from Symbian Developer Library)

◆ NewL()

static IMPORT_C CHeartbeat * CHeartbeat::NewL ( TInt  aPriority)
static

Allocates and constructs a CHeartbeat object - leaving.

Specify a high priority so the callback function is scheduled as soon as possible after the timer events complete.

Parameters
aPriorityThe priority of the active object. If timing is critical, it should be higher than that of all other active objects owned by the scheduler.

(generated from Symbian Developer Library)

◆ RunL()

IMPORT_C void CHeartbeat::RunL ( )
protectedvirtual

Handles an active object's request completion event.

A derived class must provide an implementation to handle the completed request. If appropriate, it may issue another request.

The function is called by the active scheduler when a request completion event occurs, i.e. after the active scheduler's WaitForAnyRequest() function completes.

Before calling this active object's RunL() function, the active scheduler has:

  1. decided that this is the highest priority active object with a completed request
  2. marked this active object's request as complete (i.e. the request is no longer outstanding)

RunL() runs under a trap harness in the active scheduler. If it leaves, then the active scheduler calls RunError() to handle the leave.

Note that once the active scheduler's Start() function has been called, all user code is run under one of the program's active object's RunL() or RunError() functions.

See also
CActiveScheduler::Start
CActiveScheduler::Error
CActiveScheduler::WaitForAnyRequest
TRAPD

Implements CActive.

◆ Start()

IMPORT_C void CHeartbeat::Start ( TTimerLockSpec  aLock,
MBeating *  aBeating 
)

Starts generating heartbeat events.

The event results in calls to the Beat() and Synchronize() functions specified by aBeating.

The first event is generated on the first fraction of a second corresponding to aLock that occurs after Start() has returned; subsequent events are generated regularly thereafter at one second intervals on the second fraction specified by aLock.

The aBeating mixin must be written by the user. Most of the time, its Beat() function is called which trivially updates the tick count. Occasionally, synchronisation is lost, and the Synchronize() function is called instead: this must find out from the system time how many ticks should have been counted, and update things accordingly.

Once started, heartbeat events are generated until the CHeartbeat object is destroyed.

Parameters
aLockThe fraction of a second at which the timer completes.
aBeatingProvides the Beat() and Synchronize() functions.

(generated from Symbian Developer Library)


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