ActiveProcedure< R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 > Class Template Referenceabstract

#include <Pt/Remoting/ActiveProcedure.h>

Asynchronous service procedure. More...

Inherits 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 A1 = Pt::Void, typename A2 = Pt::Void, typename A3 = Pt::Void, typename A4 = Pt::Void, typename A5 = Pt::Void, typename A6 = Pt::Void, typename A7 = Pt::Void, typename A8 = Pt::Void, typename A9 = Pt::Void, typename A10 = Pt::Void>
class Pt::Remoting::ActiveProcedure< R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 >

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.