CDeltaTimer Class Reference

class CDeltaTimer : public CActive

A queue of timed events.

A timed event is a callback function encapsulated by a TDeltaTimerEntry object, and is intended to be called when the time interval represented by the event expires.

The queue itself is a TDeltaQue list. A timed event entry is added into a position in the queue that is determined by the time interval specified for that event. Although the time interval for a timed event is specified as an interval from the present moment, when added to the queue the implementation treats each event as having an interval from the previous timed event (or now).

CDeltaTimer is an active object, driven by an RTimer which is usually set to expire upon completion of the event at the head of the queue. If the time to the next event is too great or an event at the head of the queue has been removed, the timer may be set to expire prior to the event at the head of the queue (if any).

When the timer completes, the head of the queue is inspected to see whether the timed event at the head of the queue has expired. On expiry, the callback function represented by that timed event is called, and the timed event entry is removed from the queue. The queue then inspects further events for expiry, calling and removing them as necessary until either the queue is empty or there is an event in the future to wait for.

Note that the tick period is the minimum time interval for an event and the granularity of all timings using the queue. Note that in general, any event may be called back some time after it has expired and that specifically the duration of all events will at least be rounded up to a muliple of the tick period.

TDeltaTimerEntry

TDeltaQue

RTimer

Inherits from

Constructor & Destructor Documentation

CDeltaTimer(TInt, TInt)

CDeltaTimer(TIntaPriority,
TIntaTickPeriod
)[private]

Parameters

TInt aPriority
TInt aTickPeriod

~CDeltaTimer()

~CDeltaTimer()

Member Functions Documentation

Activate(TBool)

voidActivate(TBoolaRequeueTimer = EFalse)[private]

Parameters

TBool aRequeueTimer = EFalse

DoCancel()

voidDoCancel()[private, virtual]

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

CActive::Cancel

NewL(TInt)

IMPORT_C CDeltaTimer *NewL(TIntaPriority)[static]

Parameters

TInt aPriority

NewL(TInt, TTimeIntervalMicroSeconds32)

IMPORT_C CDeltaTimer *NewL(TIntaPriority,
TTimeIntervalMicroSeconds32aGranularity
)[static]

Parameters

TInt aPriority
TTimeIntervalMicroSeconds32 aGranularity

Queue(TTimeIntervalMicroSeconds32, TDeltaTimerEntry &)

IMPORT_C voidQueue(TTimeIntervalMicroSeconds32aTimeInMicroSeconds,
TDeltaTimerEntry &aEntry
)[virtual]

Parameters

TTimeIntervalMicroSeconds32 aTimeInMicroSeconds
TDeltaTimerEntry & aEntry

QueueLong(TTimeIntervalMicroSeconds, TDeltaTimerEntry &)

IMPORT_C TIntQueueLong(TTimeIntervalMicroSecondsaTimeInMicroSeconds,
TDeltaTimerEntry &aEntry
)

Parameters

TTimeIntervalMicroSeconds aTimeInMicroSeconds
TDeltaTimerEntry & aEntry

Remove(TDeltaTimerEntry &)

IMPORT_C voidRemove(TDeltaTimerEntry &aEntry)[virtual]

Parameters

TDeltaTimerEntry & aEntry

RunL()

voidRunL()[private, virtual]

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.

CActiveScheduler::Start

CActiveScheduler::Error

CActiveScheduler::WaitForAnyRequest

TRAPD

Member Data Documentation

TTickCountQue iQueue

TTickCountQue iQueue[private]

The list of timed event entries.

TBool iQueueBusy

TBool iQueueBusy[private]

Pseudo-lock on the the queue to avoid reentrancy problems

const TInt iTickPeriod

const TIntiTickPeriod[private]

The period of a tick count.

RTimer iTimer

RTimer iTimer[private]

The asynchronous timer.