How to issue requests

This document describes how an active object issues a request for a service.

Once the active object has been constructed, a request can be issued. In the following code fragment, the active object provides the function IssueRequest() to invoke the encapsulated service function.

void CExampleActiveObject::IssueRequest()
    {
        // Request the service
    iServiceProvider-> RequestTheService(iStatus);
        // Indicate request has been issued
    SetActive();
    }
  • Pass the TRequestStatus object, provided by the active objects's CActive base class, to the service function. As part of its processing, the service function sets this to KRequestPending, indicating that the request has been issued but is not yet complete.

  • Set the base class's active request flag, using the function SetActive(), to indicate that the active object is currently active. The flag is reset by the active scheduler before handling a completed request, or by the active object base class as part of the cancellation protocol.

Completing a request

At some point, the service provider's processing completes and it calls RThread::RequestComplete() passing the request status object and the service provider's return code, a value other than KRequestPending. This results in the active object's iStatus member being set to the return code value and a signal that the request is complete.