libqi-api
2.0.6.8
|
#include <future.hpp>
Public Types | |
typedef FutureType< T >::type | ValueType |
Public Member Functions | |
Promise (FutureCallbackType async=FutureCallbackType_Async) | |
Promise (boost::function< void(qi::Promise< T >)> cancelCallback, FutureCallbackType async=FutureCallbackType_Async) | |
void | setValue (const ValueType &value) |
void | setError (const std::string &msg) |
void | setCanceled () |
void | reset () |
Future< T > | future () const |
Get a future linked to this promise. Can be called multiple times. | |
ValueType & | value () |
void | trigger () |
Protected Member Functions | |
void | setup (boost::function< void(qi::Promise< T >)> cancelCallback, FutureCallbackType async=FutureCallbackType_Async) |
Promise (Future< T > &f) | |
Protected Attributes | |
Future< T > | _f |
Friends | |
template<typename FT , typename PT > | |
void | adaptFuture (const Future< FT > &f, Promise< PT > &p) |
template<typename FT , typename PT , typename CONV > | |
void | adaptFuture (const Future< FT > &f, Promise< PT > &p, CONV converter) |
Similar to adaptFuture(f, p) but with a custom converter. |
A Promise is used to create and satisfy a Future.
Definition at line 432 of file future.hpp.
typedef FutureType<T>::type qi::Promise< T >::ValueType |
Definition at line 434 of file future.hpp.
qi::Promise< T >::Promise | ( | FutureCallbackType | async = FutureCallbackType_Async | ) | [inline, explicit] |
Create a standard promise.
async | specify how callbacks registered with Future::connect are called: synchronously from the Promise setter, or asynchronously from a thread pool. |
Definition at line 441 of file future.hpp.
qi::Promise< T >::Promise | ( | boost::function< void(qi::Promise< T >)> | cancelCallback, |
FutureCallbackType | async = FutureCallbackType_Async |
||
) | [inline, explicit] |
Create a canceleable promise. If Future<T>::cancel is invoked, onCancel() will be called. It is expected to call setValue(), setError() or setCanceled() as quickly as possible, but can do so in an asynchronous way.
Definition at line 451 of file future.hpp.
qi::Promise< T >::Promise | ( | Future< T > & | f | ) | [inline, explicit, protected] |
Definition at line 499 of file future.hpp.
Future<T> qi::Promise< T >::future | ( | ) | const [inline] |
Get a future linked to this promise. Can be called multiple times.
Definition at line 483 of file future.hpp.
void qi::Promise< T >::reset | ( | ) | [inline] |
Definition at line 478 of file future.hpp.
void qi::Promise< T >::setCanceled | ( | ) | [inline] |
set the cancel state, and notify all futures throw if state != running
Definition at line 473 of file future.hpp.
void qi::Promise< T >::setError | ( | const std::string & | msg | ) | [inline] |
set the error, and notify all futures throw if state != running
Definition at line 466 of file future.hpp.
void qi::Promise< T >::setup | ( | boost::function< void(qi::Promise< T >)> | cancelCallback, |
FutureCallbackType | async = FutureCallbackType_Async |
||
) | [inline, protected] |
Definition at line 493 of file future.hpp.
void qi::Promise< T >::setValue | ( | const ValueType & | value | ) | [inline] |
notify all future that a value has been set. throw if state != running
Definition at line 459 of file future.hpp.
void qi::Promise< T >::trigger | ( | ) | [inline] |
Trigger the promise with the current value.
Definition at line 491 of file future.hpp.
ValueType& qi::Promise< T >::value | ( | ) | [inline] |
Gives access to the underlying value for in-place modification. trigger() must be called after the value is written to trigger the promise.
Definition at line 488 of file future.hpp.
void adaptFuture | ( | const Future< FT > & | f, |
Promise< PT > & | p | ||
) | [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 314 of file future.hxx.
void adaptFuture | ( | const Future< FT > & | f, |
Promise< PT > & | p, | ||
CONV | converter | ||
) | [friend] |
Similar to adaptFuture(f, p) but with a custom converter.
Definition at line 324 of file future.hxx.
Future<T> qi::Promise< T >::_f [protected] |
Definition at line 501 of file future.hpp.