ActiveProcedure< R, ARGS > Class Template Referenceabstract

#include <Pt/Remoting/ActiveProcedure.h>

Asynchronous service procedure. More...

Inherits ServiceProcedure, and ServiceProcedure.

Public Member Functions

 ActiveProcedure (Responder &resp)
 Constructs with Responder.
 
 ~ActiveProcedure ()
 Destructor.
 
void setReady ()
 Indicates that the procedure has finished.
 

Protected Member Functions

virtual void onInvoke (System::EventLoop &loop, const ARGS...&args)=0
 Start an asynchronous procedure.
 
virtual const R & onResult ()=0
 Return result of the asynchronous procedure.
 

Detailed Description

template<typename R, typename... ARGS>
class Pt::Remoting::ActiveProcedure< R, ARGS >

Instances derived from this class are returned by the asynchronous service procedures registered in a Service. The template parameters imply the signature of the procedure. The first tempate parameter is the return value type, followed by the argument types, if any. For example, a ActiveProcedure<double, int, int> is a service procedure which returns a double and takes two ints as arguments. A ActiveProcedure<std::string> is a service procedure without arguments, only returning a std::string.

The two methods onInvoke() and onResult() need to be implemented. When a RPC request was received and dispatched to an asynchronous procedure, onInvoke() is called with the deserialized arguments and an EventLoop to execute further asynchronous operations such as I/O. It is the task of the implementer to advance progress of the procedure until a result is ready. By calling setReady(), the Responder will be notified of the completion and call onResult() to get the result and serialize it. Both methods may throw exceptions of type Fault to indicate failure.