class CActive : public CBase |
The core class of the active object abstraction.
It encapsulates both the issuing of a request to an asynchronous service provider and the handling of completed requests. An application can have one or more active objects whose processing is controlled by an active scheduler.
Public Member Functions | |
---|---|
~CActive() | |
IMPORT_C void | Cancel() |
IMPORT_C void | Deque() |
TBool | IsActive() |
TBool | IsAdded() |
TInt | Priority() |
IMPORT_C void | SetPriority(TInt) |
Protected Member Functions | |
---|---|
CActive(TInt) | |
void | DoCancel() |
IMPORT_C TInt | Extension_(TUint, TAny *&, TAny *) |
IMPORT_C TInt | RunError(TInt) |
void | RunL() |
IMPORT_C void | SetActive() |
Public Member Enumerations | |
---|---|
enum | TPriority { EPriorityIdle = -100, EPriorityLow = -20, EPriorityStandard = 0, EPriorityUserInput = 10, EPriorityHigh = 20 } |
Public Attributes | |
---|---|
TRequestStatus | iStatus |
Private Attributes | |
---|---|
TPriQueLink | iLink |
TAny * | iSpare |
void | DoCancel | ( | ) | [protected, pure 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().
IMPORT_C TInt | Extension_ | ( | TUint | aExtensionId, |
TAny *& | a0, | |||
TAny * | a1 | |||
) | [protected, virtual] |
TBool | IsActive | ( | ) | const [inline] |
Determines whether the active object has a request outstanding.
A request is outstanding when:
1. it has been issued
2. it has not been cancelled
3. it servicing has not yet begun.
True, if a request is outstanding; false, otherwise.
TBool | IsAdded | ( | ) | const [inline] |
Determines whether the active object has been added to the active scheduler's list of active objects.
If the active object has not been added to a scheduler, it cannot handle the completion of any request. No request should be issued until the active object has been added to a scheduler because completion of that request generates what appears to be a stray signal.
Use the active object function Deque() to remove the active object from the scheduler.
True, if the active object has been added to an active scheduler; false, otherwise.
TInt | Priority | ( | ) | const [inline] |
Gets the priority of the active object.
The active object's priority value.
void | RunL | ( | ) | [protected, pure 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::WaitForAnyRequest
TRAPD
Defines standard priorities for active objects.
EPriorityIdle = -100 |
A low priority, useful for active objects representing background processing. |
EPriorityLow = -20 |
A priority higher than EPriorityIdle but lower than EPriorityStandard. |
EPriorityStandard = 0 |
Most active objects will have this priority. |
EPriorityUserInput = 10 |
A priority higher than EPriorityStandard; useful for active objects handling user input. |
EPriorityHigh = 20 |
A priority higher than EPriorityUserInput. |
TRequestStatus | iStatus |
The request status associated with an asynchronous request.
This is passed as a parameter to all asynchronous service providers.
The active scheduler uses this to check whether the active object's request has completed.
The function can use the completion code to judge the success or otherwise of the request.