libqi-api  2.0.6.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
qi::Promise< T > Class Template Reference

#include <future.hpp>

List of all members.

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.
ValueTypevalue ()
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.

Detailed Description

template<typename T>
class qi::Promise< T >

A Promise is used to create and satisfy a Future.

Definition at line 432 of file future.hpp.


Member Typedef Documentation

template<typename T>
typedef FutureType<T>::type qi::Promise< T >::ValueType

Definition at line 434 of file future.hpp.


Constructor & Destructor Documentation

template<typename T>
qi::Promise< T >::Promise ( FutureCallbackType  async = FutureCallbackType_Async) [inline, explicit]

Create a standard promise.

Parameters:
asyncspecify 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.

template<typename T>
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.

template<typename T>
qi::Promise< T >::Promise ( Future< T > &  f) [inline, explicit, protected]

Definition at line 499 of file future.hpp.


Member Function Documentation

template<typename T>
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.

template<typename T>
void qi::Promise< T >::reset ( ) [inline]

Definition at line 478 of file future.hpp.

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

template<typename T>
void qi::Promise< T >::trigger ( ) [inline]

Trigger the promise with the current value.

Definition at line 491 of file future.hpp.

template<typename T>
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.


Friends And Related Function Documentation

template<typename T>
template<typename FT , typename PT >
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.

template<typename T>
template<typename FT , typename PT , typename CONV >
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.


Member Data Documentation

template<typename T>
Future<T> qi::Promise< T >::_f [protected]

Definition at line 501 of file future.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines