Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | Friends | List of all members
honey::Promise< R > Class Template Reference

Container to hold a delayed function result. More...

#include <Promise.h>

Inheritance diagram for honey::Promise< R >:
Inheritance graph
[legend]
Collaboration diagram for honey::Promise< R >:
Collaboration graph
[legend]

Public Types

typedef future::priv::State< R > State
 

Public Member Functions

template<class Alloc = std::allocator<State>>
 Promise (Alloc &&a=Alloc())
 Construct with allocator for shared state. More...
 
 Promise (Promise &&rhs) noexcept
 
 ~Promise ()
 
Promiseoperator= (Promise &&rhs)
 
Future< R > future ()
 Get future from which delayed result can be retrieved. More...
 
template<class T >
mt::disable_if< mt::True< T >::value &&(mt::isRef< R >::value||std::is_void< R >::value)>::type setValue (T &&val)
 Set stored result. Result is copy/move constructed from value. More...
 
template<class T >
std::enable_if< mt::True< T >::value &&mt::isRef< R >::value >::type setValue (T &val)
 Set stored result for ref result type. More...
 
void setValue ()
 Set stored result for void result type. More...
 
void setException (const Exception::ConstPtr &e)
 Set stored exception. More...
 
bool valid () const
 Check if this instance has state and can be used. State can be transferred out to another instance through move-assignment. More...
 
State__state () const
 Get the shared state. More...
 
template<>
void setValue ()
 

Friends

template<class R_ >
class Future
 
template<class Sig >
class PackagedTask
 

Detailed Description

template<class R>
class honey::Promise< R >

Container to hold a delayed function result.

A promise must be fulfilled before being destroyed, otherwise its future will return the exception future::Broken.

Member Typedef Documentation

template<class R>
typedef future::priv::State<R> honey::Promise< R >::State

Constructor & Destructor Documentation

template<class R>
template<class Alloc = std::allocator<State>>
honey::Promise< R >::Promise ( Alloc &&  a = Alloc())
inline

Construct with allocator for shared state.

template<class R>
honey::Promise< R >::Promise ( Promise< R > &&  rhs)
inlinenoexcept
template<class R>
honey::Promise< R >::~Promise ( )
inline

Member Function Documentation

template<class R>
State& honey::Promise< R >::__state ( ) const
inline

Get the shared state.

template<class R>
Future<R> honey::Promise< R >::future ( )
inline

Get future from which delayed result can be retrieved.

Exceptions
future::FutureAlreadyRetrievedif future() has been called more than once.
future::NoStateif invalid
template<class R>
Promise& honey::Promise< R >::operator= ( Promise< R > &&  rhs)
inline
template<class R>
void honey::Promise< R >::setException ( const Exception::ConstPtr &  e)
inline

Set stored exception.

Exceptions
future::AlreadySatisfiedif a result has already been set
future::NoStateif invalid
template<class R>
template<class T >
mt::disable_if<mt::True<T>::value && (mt::isRef<R>::value || std::is_void<R>::value)>::type honey::Promise< R >::setValue ( T &&  val)
inline

Set stored result. Result is copy/move constructed from value.

Exceptions
future::AlreadySatisfiedif a result has already been set
future::NoStateif invalid
template<class R>
template<class T >
std::enable_if<mt::True<T>::value && mt::isRef<R>::value>::type honey::Promise< R >::setValue ( T &  val)
inline

Set stored result for ref result type.

template<class R>
void honey::Promise< R >::setValue ( )
inline

Set stored result for void result type.

template<>
void honey::Promise< void >::setValue ( )
inline
template<class R>
bool honey::Promise< R >::valid ( ) const
inline

Check if this instance has state and can be used. State can be transferred out to another instance through move-assignment.

Friends And Related Function Documentation

template<class R>
template<class R_ >
friend class Future
friend
template<class R>
template<class Sig >
friend class PackagedTask
friend

The documentation for this class was generated from the following file: