Responsibilities of Asynchronous Service Provider in Active Objects
Asynchronous Service Provider provides asynchronous services using request functions and cancel functions. In general, Symbian Active Objects encapsulate Asynchronous Service Providers and their request, cancel functions and the function which handles completion of requests.
An asynchronous service provider must interact in the following ways with its clients:
- Before initiating a request, a request function must set the value of the passed TRequestStatus to KRequestPending, which indicates that a request has been issued but not completed.
- Requests must be completed by signaling the requesting thread’s request semaphore by calling RThread::RequestComplete() with the TRequestStatus as the first parameter and the completion code as the second parameter (which is placed in the TRequestStatus).
- There must be a cancel function which can cancel an outstanding request. In some cases, calling the cancel function does not cancel the operation because the request is already complete. In all cases, the request must be complete before the return of the Cancel() function.
- If an asynchronous request is made, it must complete precisely once, whether normally, abnormally, or through cancellation.
- A TRequestStatus code of KErrCancel often indicates completion through cancellation.