BasicAsyncCall< R > Class Template Referenceabstract

#include <Pt/Lua/AsyncCall.h>

Asynchronous native call with result type R. More...

Inherits AsyncCall.

Public Member Functions

void bind (Pt::Reflex::TypeManager &tm)
 Binds the result type from tm.
Pt::Reflex::Type * rtype () const
 Returns the Reflex result type, or a null pointer before bind.
void beginCall (Pt::System::EventLoop &loop)
 Starts the call on loop.
Pt::Any getResult ()
 Returns the result after the call has finished.
Pt::Signalfinished ()
 Signal emitted when the call is ready or has failed.
void cancel ()
 Cancels the call.
bool hasError () const
 Returns true when the call stored an error.
const std::string & errorMessage () const
 Returns the stored error text.

Protected Member Functions

virtual R onResult ()=0
 Returns the result of the finished call.
void setReady ()
 Emits finished() to mark the call ready.
void setError (const std::string &msg)
 Stores msg as the error of this call.

Detailed Description

template<typename R>
class Pt::Lua::BasicAsyncCall< R >

BasicAsyncCall looks up typeid(R) at bind time. Override onBeginCall() to start work on the loop, onResult() to produce R, and onCancel() to abort. Call setReady() or setError() when the work ends.