#include <genesis/utils/threading/multi_future.hpp>
Helper class to facilitate waiting for and/or getting the results of multiple futures at once.
Definition at line 83 of file multi_future.hpp.
Public Member Functions | |
MultiFuture (MultiFuture &&)=default | |
MultiFuture (MultiFuture const &)=delete | |
MultiFuture (size_t n=0) | |
Construct with the given number of futures. More... | |
~MultiFuture ()=default | |
template<typename U = T, typename std::enable_if< std::is_same< U, void >::value >::type * = nullptr> | |
void | get () |
Get the results from all the stored futures. More... | |
template<typename U = T, typename std::enable_if< !std::is_same< U, void >::value >::type * = nullptr> | |
std::vector< T > | get () |
Get the results from all the stored futures. More... | |
MultiFuture & | operator= (MultiFuture &&)=default |
MultiFuture & | operator= (MultiFuture const &)=delete |
ProactiveFuture< T > & | operator[] (size_t i) |
Get a reference to one of the stored futures. More... | |
ProactiveFuture< T > const & | operator[] (size_t i) const |
Get a const reference to one of the stored futures. More... | |
void | push_back (ProactiveFuture< T > future) |
Append a future. More... | |
size_t | size () const |
Get the number of stored futures. More... | |
bool | valid () const |
Return whether all stored futures are valid. More... | |
void | wait () const |
Wait for all the stored futures. More... | |
|
inline |
Construct with the given number of futures.
Definition at line 94 of file multi_future.hpp.
|
delete |
|
default |
|
default |
|
inline |
Get the results from all the stored futures.
This is the version for T
being void
, in which case the futures do not return a value. In this case, this function is equivalent to calling wait().
Definition at line 139 of file multi_future.hpp.
|
inline |
Get the results from all the stored futures.
This is the version for T
begin not void
. The function calls get() on all futures, and returns their values as a vector. It re-throws any stored exceptions of the futures.
Definition at line 161 of file multi_future.hpp.
|
default |
|
delete |
|
inline |
Get a reference to one of the stored futures.
Definition at line 189 of file multi_future.hpp.
|
inline |
Get a const reference to one of the stored futures.
Definition at line 197 of file multi_future.hpp.
|
inline |
Append a future.
Definition at line 114 of file multi_future.hpp.
|
inline |
Get the number of stored futures.
Definition at line 205 of file multi_future.hpp.
|
inline |
Return whether all stored futures are valid.
Definition at line 122 of file multi_future.hpp.
|
inline |
Wait for all the stored futures.
Definition at line 179 of file multi_future.hpp.