CIdle Class Reference

#include <e32base.h>

class CIdle : public CActive

Inherits from

Detailed Description

An active object that performs low-priority processing when no higher-priority active objects are ready to run.

An idle time active object together with its associated callback function may be used to implement potentially long running background tasks, such as spreadsheet recalculation and word processor repagination.

Member Attribute Documentation

iCallBack

TCallBack iCallBack[protected]

The callback object that encapsulates the background task.

See also: Start

Constructor & Destructor Documentation

CIdle ( TInt )

IMPORT_CCIdle(TIntaPriority)[protected]

Protected constructor taking a priority value.

Sets this active object's priority value.

ParameterDescription
aPriorityThe active object priority value.

~CIdle ( )

IMPORT_C~CIdle()

Frees resources prior to destruction.

Specifically, it cancels any outstanding request.

Member Function Documentation

DoCancel ( )

IMPORT_C voidDoCancel()[protected, virtual]

Reimplemented from CActive::DoCancel()

Implements the cancellation of an outstanding request.

This function is called by the active object's Cancel() function.

See also: CActive::DoCancel

New ( TInt )

IMPORT_C CIdle *New(TIntaPriority)[static]

Allocates and initialises an Idle time active object and adds it to the active scheduler.

ParameterDescription
aPriorityAn integer specifying the priority of this active object. It must be lower than that of all other active objects on the active scheduler. The value CActive::TPriority::EPriorityIdle is recommended.

Returns: Pointer to the new Idle time active object, or NULL if the object could not be created.

NewL ( TInt )

IMPORT_C CIdle *NewL(TIntaPriority)[static]

Allocates and initialises an Idle time active object, adds it to the active scheduler, but leaves on failure.

ParameterDescription
aPriorityAn integer specifying the priority of this active object. It must be lower than that of all other active objects on the active scheduler. The value CActive::TPriority::EPriorityIdle is recommended.

Returns: Pointer to the new Idle time active object.

RunL ( )

IMPORT_C voidRunL()[protected, virtual]

Reimplemented from CActive::RunL()

Handles this idle active object's request completion event.

It is called when nothing of a higher priority can be scheduled.

See also: CActive::RunL

Start ( TCallBack )

IMPORT_C voidStart(TCallBackaCallBack)

Starts the background task.

The background task is encapsulated in the callback. The function represented by this callback is called every time this Idle time active object is scheduled to run.

The callback function should be structured to perform a background task in many increments, i.e. it should voluntarily relinquish control (i.e. return) after a suitable time interval to allow other, higher priority events to be handled.

If the callback function has further work to do, it should return a true value. This ensures that the active object is scheduled to run again later.

Once the callback function has finally completed its work, it should return a false value. The active object is then no longer scheduled to run.

ParameterDescription
aCallBackA callback object encapsulating a function which is called when no higher priority active object is ready to run.