libqi-api
2.8.7.4
|
#include <executioncontext.hpp>
Public Types | |
using | ValueType = typename detail::FutureType< T >::type |
using | ValueTypeCast = typename detail::FutureType< T >::typecast |
using | TemplateValue = T |
using | Connection = boost::function< void(Future< T >)> |
Public Member Functions | |
Future () | |
Future (const Future< T > &b) | |
bool | operator== (const Future< T > &other) const |
Future< T > & | operator= (const Future< T > &b) |
bool | operator< (const Future< T > &b) const |
FutureUniqueId | uniqueId () const |
bool | isValid () const |
Future (const ValueType &v, FutureCallbackType async=FutureCallbackType_Auto) | |
const ValueType & | value (int msecs=FutureTimeout_Infinite) const |
Return the value associated to a Future. More... | |
const ValueType & | value (Either< MilliSeconds, Infinity > timeout) const |
ValueType | valueCopy (Either< MilliSeconds, Infinity > timeout=Infinity{}) const |
Return by copy the value associated to a Future. More... | |
boost::shared_ptr< const T > | valueSharedPtr (Either< MilliSeconds, Infinity > timeout=Infinity{}) const |
Return a shared pointer to the value associated to a Future. More... | |
ValueType | operator* () const |
Return the value associated to a Future. More... | |
operator const ValueTypeCast & () const | |
FutureState | wait (int msecs=FutureTimeout_Infinite) const |
FutureState | wait (qi::Duration duration) const |
FutureState | waitFor (qi::Duration duration) const |
FutureState | wait (qi::SteadyClock::time_point timepoint) const |
FutureState | waitUntil (qi::SteadyClock::time_point timepoint) const |
bool | isFinished () const |
bool | isRunning () const |
bool | isCanceled () const |
bool | hasError (int msecs=FutureTimeout_Infinite) const |
bool | hasValue (int msecs=FutureTimeout_Infinite) const |
const std::string & | error (int msecs=FutureTimeout_Infinite) const |
FutureSync< T > | sync () |
void | cancel () |
bool | isCancelable () const |
template<typename R , typename AF > | |
Future< R > | thenR (FutureCallbackType type, AF &&func) |
Execute a callback when the future is finished. More... | |
template<typename R , typename AF > | |
Future< R > | thenR (AF &&func) |
Same as thenR(), but with type defaulted to FutureCallbackType_Auto. More... | |
template<typename R , typename AF , typename Arg0 , typename... Args> | |
Future< R > | thenR (AF &&func, Arg0 &&arg0, Args &&...args) |
template<typename R , typename AF , typename Arg0 , typename... Args> | |
Future< R > | thenR (FutureCallbackType type, AF &&func, Arg0 &&arg0, Args &&...args) |
template<typename F > | |
auto | then (FutureCallbackType type, F &&func) -> Future< typename std::result_of< F(Future< T >)>::type > |
Execute a callback when the future is finished. More... | |
template<typename AF > | |
auto | then (AF &&func) -> Future< typename std::result_of< AF(Future< T >)>::type > |
Same as then(), but with type defaulted to FutureCallbackType_Auto. More... | |
template<typename R , typename AF > | |
Future< R > | andThenR (FutureCallbackType type, AF &&func) |
Same as thenR(), but the callback is called only if this future finishes with a value. More... | |
template<typename R , typename AF > | |
Future< R > | andThenR (AF &&func) |
Same as andThenR(), but with type defaulted to FutureCallbackType_Auto. More... | |
template<typename F > | |
auto | andThen (FutureCallbackType type, F &&func) -> Future< typename std::decay< typename std::result_of< F(ValueType)>::type >::type > |
Same as then(), but the callback is called only if this future finishes with a value. More... | |
template<typename AF > | |
auto | andThen (AF &&func) -> Future< typename std::decay< typename std::result_of< AF(ValueType)>::type >::type > |
Same as andThen(), but with type defaulted to FutureCallbackType_Auto. More... | |
boost::function< void()> | makeCanceler () |
Get a functor that will cancel the future. More... | |
template<typename AF > | |
void | connect (const AF &fun, FutureCallbackType type=FutureCallbackType_Auto) |
template<typename FUNCTYPE , typename ARG0 > | |
void | connect (FUNCTYPE fun, ARG0 tracked,..., FutureCallbackType type=FutureCallbackType_Auto) |
void | connectWithStrand (qi::Strand *strand, const boost::function< void(const Future< T > &)> &cb) |
void | connectWithStrand (qi::Strand &strand, const boost::function< void(const Future< T > &)> &cb) |
void | _connect (const boost::function< void()> &s) |
template<typename R , typename F > | |
Future< R > | thenRImpl (FutureCallbackType callbackType, F &&continuation) |
template<typename R , typename F > | |
Future< R > | andThenRImpl (FutureCallbackType callbackType, F &&continuation) |
Protected Member Functions | |
boost::shared_ptr < detail::FutureBaseTyped< T > > | impl () |
An accessor to the shared state. TODO: remove it, it should not exist. More... | |
Future (boost::shared_ptr< detail::FutureBaseTyped< T > > p) | |
The constructor from the shared state. More... | |
Protected Attributes | |
boost::shared_ptr < detail::FutureBaseTyped< T > > | _p |
Friends | |
class | ExecutionContext |
class | Promise< T > |
class | FutureSync< T > |
class | detail::AddUnwrap< T > |
class | ServiceBoundObject |
template<typename R > | |
void | adaptFutureUnwrap (Future< AnyReference > &f, Promise< R > &p) |
Feed a promise from a generic future which may be unwrapped if it contains itself a future. More... | |
template<typename FT , typename PT > | |
void | adaptFuture (const Future< FT > &f, Promise< PT > &p, AdaptFutureOption option) |
Feed a promise from a future of possibly different type. More... | |
template<typename FT , typename PT , typename CONV > | |
void | adaptFuture (const Future< FT > &f, Promise< PT > &p, CONV converter, AdaptFutureOption option) |
Similar to adaptFuture(f, p) but with a custom converter. More... | |
template<typename R > | |
void | adaptFuture (Future< AnyReference > &f, Promise< R > &p) |
template<typename FT > | |
void | detail::futureCancelAdapter (boost::weak_ptr< detail::FutureBaseTyped< FT > > wf) |
Class that represents a value that will be set later in time.
Definition at line 20 of file executioncontext.hpp.
using qi::Future< T >::Connection = boost::function<void(Future<T>)> |
Definition at line 533 of file future_fwd.hpp.
using qi::Future< T >::TemplateValue = T |
Definition at line 189 of file future_fwd.hpp.
using qi::Future< T >::ValueType = typename detail::FutureType<T>::type |
Definition at line 187 of file future_fwd.hpp.
using qi::Future< T >::ValueTypeCast = typename detail::FutureType<T>::typecast |
Definition at line 188 of file future_fwd.hpp.
|
inline |
Definition at line 192 of file future_fwd.hpp.
|
inline |
Definition at line 197 of file future_fwd.hpp.
|
inlineexplicit |
Construct a Future that already contains a value.
Definition at line 230 of file future_fwd.hpp.
|
inlineprotected |
The constructor from the shared state.
Definition at line 591 of file future_fwd.hpp.
|
inline |
Definition at line 578 of file future_fwd.hpp.
|
inline |
Same as then(), but the callback is called only if this future finishes with a value.
The callback will receive the value of this future, as opposed to this future itself. In the case of Future<void>, the callback shall accept a void* parameter.
If this future finishes with an error or a cancel, the callback will not be called and the returned future will finish in the same state.
Definition at line 506 of file future_fwd.hpp.
|
inline |
Same as andThen(), but with type defaulted to FutureCallbackType_Auto.
Definition at line 516 of file future_fwd.hpp.
|
inline |
Same as thenR(), but the callback is called only if this future finishes with a value.
The callback will receive the value of this future, as opposed to this future itself. In the case of Future<void>, the callback shall accept a void* parameter.
If this future finishes with an error or a cancel, the callback will not be called and the returned future will finish in the same state.
Definition at line 89 of file future.hxx.
|
inline |
Same as andThenR(), but with type defaulted to FutureCallbackType_Auto.
Definition at line 491 of file future_fwd.hpp.
|
inline |
Definition at line 96 of file future.hxx.
|
inline |
cancel() the asynchronous operation if possible Exact effect is controlled by the cancel implementation, but it is expected to set a value or an error to the Future as fast as possible. Note that cancelation may be asynchronous.
Definition at line 383 of file future_fwd.hpp.
|
inline |
Connect a callback function that will be called once when the Future finishes (that is, switches from running to an other state).
If type is sync, connect may block and call the callback synchronously if the future is already set.
It guaranteed that your callback will be called exactly once (unless the promise is never set or the promise is reset, which is deprecated).
Definition at line 545 of file future_fwd.hpp.
void qi::Future< T >::connect | ( | FUNCTYPE | fun, |
ARG0 | tracked, | ||
..., | |||
FutureCallbackType | type = FutureCallbackType_Auto |
||
) |
Connect a callback with binding and tracking support.
If the first argument is a weak_ptr or a pointer inheriting from qi::Trackable, the callback will not be called if tracked object was destroyed.
void qi::Future< T >::connectWithStrand | ( | qi::Strand * | strand, |
const boost::function< void(const Future< T > &)> & | cb | ||
) |
Definition at line 126 of file future.hxx.
void qi::Future< T >::connectWithStrand | ( | qi::Strand & | strand, |
const boost::function< void(const Future< T > &)> & | cb | ||
) |
Definition at line 133 of file future.hxx.
|
inline |
msecs |
Definition at line 367 of file future_fwd.hpp.
|
inline |
msecs | timeout |
Definition at line 348 of file future_fwd.hpp.
|
inline |
msecs | timeout |
Definition at line 358 of file future_fwd.hpp.
|
inlineprotected |
An accessor to the shared state. TODO: remove it, it should not exist.
Definition at line 588 of file future_fwd.hpp.
|
inline |
|
inline |
Definition at line 339 of file future_fwd.hpp.
|
inline |
Definition at line 323 of file future_fwd.hpp.
|
inline |
Definition at line 330 of file future_fwd.hpp.
|
inline |
Definition at line 223 of file future_fwd.hpp.
boost::function< void()> qi::Future< T >::makeCanceler | ( | ) |
Get a functor that will cancel the future.
This functor will not keep the future alive, which is useful to avoid reference cycles. If the future does not exist anymore, this is a no-op.
Definition at line 153 of file future.hxx.
|
inline |
same as value() with an infinite timeout.
Definition at line 289 of file future_fwd.hpp.
|
inline |
Return the value associated to a Future.
valueCopy(FutureTimeout_Infinite)
. Definition at line 281 of file future_fwd.hpp.
|
inline |
Definition at line 212 of file future_fwd.hpp.
|
inline |
Definition at line 206 of file future_fwd.hpp.
|
inline |
Definition at line 201 of file future_fwd.hpp.
|
inline |
Make the future sync Should not be useful, use wait().
Definition at line 373 of file future_fwd.hpp.
|
inline |
Execute a callback when the future is finished.
The callback will receive this future as argument and all other arguments passed to this function.
If the first argument bound to this function is a weak_ptr it will be locked. If it is a Trackable, the callback won't be called after the object's destruction. If it is an Actor, the call will be stranded.
Definition at line 453 of file future_fwd.hpp.
|
inline |
Same as then(), but with type defaulted to FutureCallbackType_Auto.
Definition at line 463 of file future_fwd.hpp.
|
inline |
Execute a callback when the future is finished.
The callback will receive this future as argument and all other arguments passed to this function.
If the first argument bound to this function is a weak_ptr it will be locked. If it is a Trackable, the callback won't be called after the object's destruction. If it is an Actor, the call will be stranded.
R | the return type of your callback as it is hard to deduce without C++11. |
Definition at line 58 of file future.hxx.
|
inline |
Same as thenR(), but with type defaulted to FutureCallbackType_Auto.
Definition at line 423 of file future_fwd.hpp.
Future< R > qi::Future< T >::thenR | ( | AF && | func, |
Arg0 && | arg0, | ||
Args &&... | args | ||
) |
Definition at line 1240 of file future_fwd.hpp.
Future< R > qi::Future< T >::thenR | ( | FutureCallbackType | type, |
AF && | func, | ||
Arg0 && | arg0, | ||
Args &&... | args | ||
) |
Definition at line 1249 of file future_fwd.hpp.
|
inline |
Definition at line 65 of file future.hxx.
|
inline |
Definition at line 217 of file future_fwd.hpp.
|
inline |
Return the value associated to a Future.
msecs | timeout |
This function can throw for many reason:
if an error is set, then value throw a FutureUserException, others errors are FutureException.
Definition at line 249 of file future_fwd.hpp.
|
inline |
Definition at line 254 of file future_fwd.hpp.
|
inline |
Return by copy the value associated to a Future.
Definition at line 262 of file future_fwd.hpp.
|
inline |
Return a shared pointer to the value associated to a Future.
Definition at line 271 of file future_fwd.hpp.
|
inline |
Wait for future to contain a value or an error
msecs | Maximum time to wait in milliseconds, 0 means return immediately. |
Definition at line 296 of file future_fwd.hpp.
|
inline |
Wait for future to contain a value or an error
duration | Maximum time to wait |
Definition at line 303 of file future_fwd.hpp.
|
inline |
Wait for future to contain a value or an error
timepoint | Time until which we can wait |
Definition at line 313 of file future_fwd.hpp.
|
inline |
Definition at line 306 of file future_fwd.hpp.
|
inline |
Definition at line 316 of file future_fwd.hpp.
|
friend |
Feed a promise from a future of possibly different type.
Will monitor f
, and bounce its state to p
. Error and canceled state are bounced as is. Valued state is bounced through FutureValueConverter<FT, PT>::convert()
Definition at line 537 of file future.hxx.
|
friend |
Similar to adaptFuture(f, p) but with a custom converter.
Definition at line 547 of file future.hxx.
|
friend |
|
friend |
Feed a promise from a generic future which may be unwrapped if it contains itself a future.
Definition at line 528 of file future.hxx.
|
friend |
Definition at line 615 of file future_fwd.hpp.
|
friend |
|
friend |
Definition at line 584 of file future_fwd.hpp.
|
friend |
Definition at line 600 of file future_fwd.hpp.
|
friend |
Definition at line 599 of file future_fwd.hpp.
|
friend |
Definition at line 618 of file future_fwd.hpp.
|
protected |
Definition at line 598 of file future_fwd.hpp.