×
Namespaces

Variants
Actions

Timers

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: vvsnaresh (03 Apr 2007)
Last edited: hamishwillee (26 Jul 2012)

Contents

Introduction

Timers are real essentials in many of the Symbian applications. There are timers in Symbian OS which fullfills both synchronous and asynchronous needs.

Some of the timing services are:


User::At

Type: Synchronous

Suspends the current thread until the specified absolute time. If the machine is off at that time, the machine will be turned on again.

static IMPORT_C TInt At(const TTime &aTime);
 
TInt is the return value:
On completion, contains the status of the request to suspend the current thread

User::After

Type: Synchronous

Suspends the current thread until a specified time interval has expired.

static IMPORT_C void After(TTimeIntervalMicroSeconds32 aInterval);
 
Here, aInterval is in microseconds
 
Panic Codes:USER,86,if the time interval is negative.


RTimer

Type: Asynchronous

This is a base for asynchronous timer implementations.

Some types of asynchronous request supported by the class are:

-RTimer::After()      - Requests an event after the specified interval.
 
-RTimer::AfterTicks() - Requests an event after the specified interval.
 
-RTimer::At() - Requests an event at a given system time
(in the current time zone).
 
-RTimer::AtUTC() - Requests an event at a given UTC time.
 
-RTimer::Cancel() - Cancels any outstanding request for a timer event.
 
-RTimer::CreateLocal()- Creates a thread-relative timer.
 
-RTimer::HighRes() - Requests an event after the specified interval to a
resolution of 1ms.
 
-RTimer::Inactivity() - Requests an event if the specified time interval elapses
without user actvity.
 
-RTimer::Lock() - Requests an event on a specified second fraction.

CTimer

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(Stores and manipulates the date and time.It represents a date and time as a number of microseconds), or after an interval specified in microseconds.

The RunL() virtual member function is called by the active scheduler after this event occurs.

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.

CDeltaTimer,CPeriodic and CHeartbeat classes are derived from CTimer and answer most timing needs.


CPeriodic

In order to implement a periodic timer, this uses RTimer::After.


CHeartbeat

This uses RTimer::Lock to implement a fraction of a second timer capable of detecting and informing lost heartbeats.


CDeltaTimer

This uses RTimer::After to implement a queue of variable length timer intervals.


Note: The accuracy of timers both on EKA1 and EKA2 is 1/64th of a second. EKA2 also provides higher resolution (one ms) timers via RTimer::HighRes() and User::AfterHighRes(). Timer accuracy can be checked with HAL::Get(HALData::ESystemTickPeriod, tickPeriod).


Related:


--

This page was last modified on 26 July 2012, at 07:05.
49 page views in the last 30 days.