MIRA
|
An RPCFuture is a proxy for the result of an asynchronous RPC call. More...
#include <rpc/RPCFuture.h>
Public Types | |
typedef boost::detail::future_traits< R >::move_dest_type | ReturnValue |
The rvalue return value, which essentially can be thought of R&&. More... | |
Public Member Functions | |
RPCFuture () | |
RPCFuture (boost::unique_future< R > other, AbstractRPCClient *client, const std::string &callId) | |
internally used by RPCClient More... | |
RPCFuture (RPCFuture &&other) noexcept | |
move constructor More... | |
RPCFuture & | operator= (RPCFuture &&other) noexcept |
move assignment operator More... | |
operator ReturnValue () | |
Casts the return value of the RPC call associated to this future to R&&. More... | |
ReturnValue | get (bool throwXRPC=true, bool recursive=true) |
Obtains the return value of the RPC call associated to this future as rvalue R&&. More... | |
const std::string & | callId () |
query call ID More... | |
bool | isReady () const |
Checks to see if the result of the RPC call associated with this future is set. More... | |
bool | hasException () const |
Returns true if the RPC call associated with this future has finished with an exception rather than a return value. More... | |
bool | hasValue () const |
Returns true if the RPC call associated with this future has finished with a return value value rather than an exception. More... | |
void | wait () const |
Waits and blocks the current thread until the result of the associated RPC call is ready. More... | |
template<typename Duration > | |
bool | timedWait (Duration const &relTime) const |
Waits and blocks the current thread until the result of the associated RPC call is ready, or the time duration specified by waitDuration has elapsed. More... | |
bool | timedWaitUntil (boost::system_time const &absTime) const |
Waits and blocks the current thread until the result of the associated RPC call is ready, or the time point specified by waitDuration has passed. More... | |
void | swap (RPCFutureCommon< R > &other) |
Swaps ownership of the asynchronous results associated with other and *this. More... | |
Protected Attributes | |
AbstractRPCClient * | mClient |
std::string | mCallId |
boost::unique_future< R > | mFuture |
An RPCFuture is a proxy for the result of an asynchronous RPC call.
It can be used to block the calling thread until the RPC call has finished and the result is available. The use of futures dramatically reduces latency in RPC calls, since the caller can decide whether it wants to wait for the result or not and where it wants to wait for the result.
The RPCFuture cannot be shared, however, the ownership can be transferred between different instances using the move constructor or move-assignment operator, but at most one instance holds a reference to a given asynchronous result. When the result is ready, it can be returned using get() by rvalue-reference to allow the result to be moved or copied as appropriate for the type.
typedef boost::detail::future_traits<R>::move_dest_type ReturnValue |
The rvalue return value, which essentially can be thought of R&&.
|
inline |
|
inline |
internally used by RPCClient
|
inline |
Casts the return value of the RPC call associated to this future to R&&.
|
inline |
Obtains the return value of the RPC call associated to this future as rvalue R&&.
[in] | throwXRPC | throw XRPC instead of original exception that occured in the called function (default = true, for backward compatibility) |
[in] | recursive | recurse to innermost exception (for nested XRPC, only if throwXRPC=false) |
|
inlineinherited |
query call ID
|
inlineinherited |
Checks to see if the result of the RPC call associated with this future is set.
|
inlineinherited |
Returns true if the RPC call associated with this future has finished with an exception rather than a return value.
|
inlineinherited |
Returns true if the RPC call associated with this future has finished with a return value value rather than an exception.
|
inlineinherited |
Waits and blocks the current thread until the result of the associated RPC call is ready.
This is an interruption point.
|
inlineinherited |
Waits and blocks the current thread until the result of the associated RPC call is ready, or the time duration specified by waitDuration has elapsed.
This is an interruption point.
|
inlineinherited |
Waits and blocks the current thread until the result of the associated RPC call is ready, or the time point specified by waitDuration has passed.
This is an interruption point.
|
inlineinherited |
Swaps ownership of the asynchronous results associated with other and *this.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |