class CAsyncRequest : public CActive |
An outstanding request on the server side. A subclass should be created for each type of outstanding request.
This class is implemented as an active object, because it is anticipated that some asynchronous requests can be implemented simply by completing the client request when a TRequestStatus completes. The implementor can override this behavior by re-implementing RunL, e.g. to free some resources before completing the request. If they do so, they must call CompleteAndMarkForDeletion to complete the client request and mark this object for deletion (alternatively they can simply call CAsyncRequest::RunL from their RunL).
This class cannot, however, anticipate the cancellation mechanism. The implementor must implement DoCancel for that. DoCancel should not delete the client request or mark this object for deletion.
When the implementor has allocated an instance of this class, they must add it to the session by calling CAsyncRequest::TransferToScsFrameworkL . The second-phase constructor must not leave between that and calling SetActive.
These objects are cancelled and destroyed when the client-side session / subsession sends a cancel command.
CScsSession::AddAsyncRequestL
Public Member Functions | |
---|---|
CAsyncRequest ( CScsSession *, CScsSubsession *, const RMessage2 &) | |
void | CancelCompleteAndMarkForDeletion () |
IMPORT_C void | DoCleanup () |
void | MarkForDeletion () |
IMPORT_C void | TransferToScsFrameworkL () |
Protected Member Functions | |
---|---|
IMPORT_C void | CompleteAndMarkForDeletion ( TInt ) |
IMPORT_C TInt | RunError ( TInt ) |
IMPORT_C void | RunL () |
Inherited Enumerations | |
---|---|
CActive:TPriority |
Public Attributes | |
---|---|
TInt | iFunction |
const RMessagePtr2 | iMessagePtr2 |
CScsSession * | iSession |
CScsSubsession * | iSubsession |
Inherited Attributes | |
---|---|
CActive::iStatus |
IMPORT_C | CAsyncRequest | ( | CScsSession * | aSession, |
CScsSubsession * | aSubsession, | |||
const RMessage2 & | aMessage | |||
) |
Record the session, subsession, and function associated with this request. These are required to complete or to cancel the request later.
Adds this object to the active scheduler.
CScsSession * aSession | Session used to launch this request. |
CScsSubsession * aSubsession | Subsession on which this request is queued. This should be NULL if the request is relative to a session, instead of a subsession |
const RMessage2 & aMessage | Handle to the kernel-side request object, which will be completed later. |
void | CancelCompleteAndMarkForDeletion | ( | ) |
Cancel this asynchronous request and complete the client request with KErrCancel. On exit, this object has been marked for deletion.
IMPORT_C void | CompleteAndMarkForDeletion | ( | TInt | aError | ) | [protected] |
Completes the client-side request associated with this asynchronous request and marks this object for deletion.
If the error was because the client passed a bad descriptor then panick the client instead of completing the request for consistency with synchronous requests.
TInt aError | Error code with which the client request will be completed. |
IMPORT_C void | DoCleanup | ( | ) | [virtual] |
This virtual function is called whenever the SCS needs to cancel an operation.
If the asynchronous request implementation ALWAYS has an internal request active for the duration of the client request, then this default implementation can be used, which simply calls CActive::Cancel which will call the derived classe's DoCancel (if, and only if the object IsActive).
A more complex case is where the asynchronous requests may enter an internal queue where the client request is (obviously still active), but the derived class has not outstanding request. In this case the default implementation will cause a HANG, because Cancel will not call DoCancel if the object is not active...
In the generic case, the derived class should provide an overload for the Cleanup method. This function should call Cancel to cancel any outstanding operation, then perform whatever other cleanup is required to cleanup the request (closing handles, removing from queues etc). The framework will then complete the client request.
nb. The destructor of the CAsyncRequest may not run until sometime after the client request has been completed.
void | MarkForDeletion | ( | ) |
Mark this outstanding request for deletion, so it is cleaned up when the cleanup AO runs.
IMPORT_C TInt | RunError | ( | TInt | aError | ) | [protected, virtual] |
Override CActive by completing the request with the supplied error code and marking this object for deletion. The default implementation of RunL cannot leave, but the subclass may override it with a more complex implementation.
TInt aError | Error code with which aError left. |
IMPORT_C void | RunL | ( | ) | [protected, virtual] |
Implement CActive by completing the server client's request status with the AO error code, i.e. iStatus. This function also marks this object for deletion.
If a subclass overrides this implementation then it must call CompleteAndMarkForDeletion itself to complete the client-side request.
IMPORT_C void | TransferToScsFrameworkL | ( | ) |
Adds this asynchronous request to the global collection. This should be called after the subclass has performed its own initialization, but before the active request has been set up.
CScsSession * | iSession |
Session on which this request is queued. NULL if completed.
CScsSubsession * | iSubsession |
Subsession on which this request is queued. NULL if session-relative.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.