Wednesday, May 23, 2007

Asynchronous service provider

An asynchronous service provider (ASP) has to store a reference (better is a pointer) to the callers TRequestStatus variable as its own member variable. In most cases the caller of an asynchronous function is an Active Object (AO) which has a TRequestStatus membervariable. Storing a pointer is better so it does not have to be intialized when constructing the ASP object. When calling the ASP's asynchronous function the reference/pointer to the caller's TRequestStatus is set to KRequestPending. A check can also be performed (if iCallerStatus is already set leave with KErrInUse exception). After this the asynchronous task is performed. When it is finished the ASP calls User::RequestComplete(iCallerStatus, aResultCode). In this case the AO's RunL eventhandling method is called.