Honeycomb  0.1
Component-Model Framework
Classes | Enumerations | Functions
honey::future Namespace Reference

Future util. More...

Classes

struct  AlreadySatisfied
 
struct  AsyncSched
 
struct  AsyncSched_tag
 
struct  Broken
 Exceptions. More...
 
struct  FutureAlreadyRetrieved
 
struct  NoState
 

Enumerations

enum  Status { Status::ready, Status::timeout }
 

Functions

void waitAll ()
 
template<class Future , class... Futures, typename mt::disable_if< mt::isRange< Future >::value, int >::type = 0>
void waitAll (Future &&f, Futures &&...fs)
 Wait until all futures are ready. More...
 
template<class Range , class Clock , class Dur , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
void waitAll (Range &&range, TimePoint< Clock, Dur > time)
 Wait until all futures in a range are ready or until a certain time. More...
 
template<class Range , class Rep , class Period , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
void waitAll (Range &&range, Duration< Rep, Period > time)
 Wait until all futures in a range are ready or until an amount of time has passed. More...
 
template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
void waitAll (Range &&range)
 Wait until all futures in a range are ready. More...
 
template<class Future , class... Futures, typename mt::disable_if< mt::isRange< Future >::value, int >::type = 0>
int waitAny (Future &&f, Futures &&...fs)
 Wait until any futures are ready, returns index of ready future. More...
 
template<class Range , class Clock , class Dur , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
auto waitAny (Range &&range, TimePoint< Clock, Dur > time) -> mt_iterOf(range)
 Wait until any futures in a range are ready or until a certain time, returns iterator to ready future or range end if timed out. More...
 
template<class Range , class Rep , class Period , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
auto waitAny (Range &&range, Duration< Rep, Period > time) -> mt_iterOf(range)
 Wait until any futures in a range are ready or until an amount of time has passed, returns iterator to ready future or range end if timed out. More...
 
template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
auto waitAny (Range &&range) -> mt_iterOf(range)
 Wait until any futures in a range are ready, returns iterator to ready future. More...
 
AsyncSchedasync_createSingleton ()
 Default implementation. More...
 
template<class Sched , class Func , class... Args, typename std::enable_if< mt::is_base_of< AsyncSched_tag, Sched >::value, int >::type = 0>
Future< typename std::result_of< Func(Args...)>::type > async (Sched &&sched, Func &&f, Args &&...args)
 Call a function asynchronously, returns a future with the result of the function call. More...
 
template<class Func , class... Args>
Future< typename std::result_of< Func(Args...)>::type > async (Func &&f, Args &&...args)
 Async using global scheduler. More...
 
Future< tuple<> > whenAll ()
 
template<class... Futures, class Result_ = typename std::decay<typename mt::removeRef<mt::typeAt<0, Futures...>>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, void, tuple<typename std::decay<typename mt::removeRef<Futures>::type::Result>::type...>>::type>
Future< Result > whenAll (Futures &&...fs)
 Returns a future to either a tuple of the results of all futures, or the first exception thrown by the futures. More...
 
template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0, class Result_ = typename std::decay<typename mt::elemOf<Range>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, void, vector<Result_>>::type>
Future< Result > whenAll (Range &&range)
 whenAll() for a range of futures More...
 
template<class... Futures, class Result_ = typename std::decay<typename mt::removeRef<mt::typeAt<0, Futures...>>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, int, tuple<int, Result_>>::type>
Future< Result > whenAny (Futures &&...fs)
 Returns a future to a tuple of the index of the ready future and its result. More...
 
template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0, class Result_ = typename std::decay<typename mt::elemOf<Range>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, typename mt::iterOf<Range>::type, tuple<typename mt::iterOf<Range>::type, Result_>>::type>
Future< Result > whenAny (Range &&range)
 whenAny() for a range of futures More...
 

Detailed Description

Future util.

Enumeration Type Documentation

enum honey::future::Status
strong
Enumerator
ready 

the future result is ready

timeout 

timeout expired

Function Documentation

template<class Sched , class Func , class... Args, typename std::enable_if< mt::is_base_of< AsyncSched_tag, Sched >::value, int >::type = 0>
Future<typename std::result_of<Func(Args...)>::type> honey::future::async ( Sched &&  sched,
Func &&  f,
Args &&...  args 
)

Call a function asynchronously, returns a future with the result of the function call.

template<class Func , class... Args>
Future<typename std::result_of<Func(Args...)>::type> honey::future::async ( Func &&  f,
Args &&...  args 
)

Async using global scheduler.

To provide a custom global scheduler define future_async_createSingleton and implement future::async_createSingleton().

AsyncSched * honey::future::async_createSingleton ( )
inline

Default implementation.

void honey::future::waitAll ( )
inline
template<class Future , class... Futures, typename mt::disable_if< mt::isRange< Future >::value, int >::type = 0>
void honey::future::waitAll ( Future &&  f,
Futures &&...  fs 
)

Wait until all futures are ready.

template<class Range , class Clock , class Dur , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
void honey::future::waitAll ( Range &&  range,
TimePoint< Clock, Dur >  time 
)

Wait until all futures in a range are ready or until a certain time.

template<class Range , class Rep , class Period , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
void honey::future::waitAll ( Range &&  range,
Duration< Rep, Period >  time 
)

Wait until all futures in a range are ready or until an amount of time has passed.

template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
void honey::future::waitAll ( Range &&  range)

Wait until all futures in a range are ready.

template<class Future , class... Futures, typename mt::disable_if< mt::isRange< Future >::value, int >::type = 0>
int honey::future::waitAny ( Future &&  f,
Futures &&...  fs 
)

Wait until any futures are ready, returns index of ready future.

template<class Range , class Clock , class Dur , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
auto honey::future::waitAny ( Range &&  range,
TimePoint< Clock, Dur >  time 
) -> mt_iterOf(range)

Wait until any futures in a range are ready or until a certain time, returns iterator to ready future or range end if timed out.

template<class Range , class Rep , class Period , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
auto honey::future::waitAny ( Range &&  range,
Duration< Rep, Period >  time 
) -> mt_iterOf(range)

Wait until any futures in a range are ready or until an amount of time has passed, returns iterator to ready future or range end if timed out.

template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0>
auto honey::future::waitAny ( Range &&  range) -> mt_iterOf(range)

Wait until any futures in a range are ready, returns iterator to ready future.

Future<tuple<> > honey::future::whenAll ( )
inline
template<class... Futures, class Result_ = typename std::decay<typename mt::removeRef<mt::typeAt<0, Futures...>>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, void, tuple<typename std::decay<typename mt::removeRef<Futures>::type::Result>::type...>>::type>
Future<Result> honey::future::whenAll ( Futures &&...  fs)

Returns a future to either a tuple of the results of all futures, or the first exception thrown by the futures.

template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0, class Result_ = typename std::decay<typename mt::elemOf<Range>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, void, vector<Result_>>::type>
Future<Result> honey::future::whenAll ( Range &&  range)

whenAll() for a range of futures

template<class... Futures, class Result_ = typename std::decay<typename mt::removeRef<mt::typeAt<0, Futures...>>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, int, tuple<int, Result_>>::type>
Future<Result> honey::future::whenAny ( Futures &&...  fs)

Returns a future to a tuple of the index of the ready future and its result.

template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0, class Result_ = typename std::decay<typename mt::elemOf<Range>::type::Result>::type, class Result = typename std::conditional< std::is_same<Result_, void>::value, typename mt::iterOf<Range>::type, tuple<typename mt::iterOf<Range>::type, Result_>>::type>
Future<Result> honey::future::whenAny ( Range &&  range)

whenAny() for a range of futures