A library for working with phylogenetic and population genetic data.
v0.32.0
MultiFuture< T > Class Template Reference

#include <genesis/utils/threading/multi_future.hpp>

Detailed Description

template<typename T>
class genesis::utils::MultiFuture< T >

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...
 
MultiFutureoperator= (MultiFuture &&)=default
 
MultiFutureoperator= (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...
 

Constructor & Destructor Documentation

◆ MultiFuture() [1/3]

MultiFuture ( size_t  n = 0)
inline

Construct with the given number of futures.

Definition at line 94 of file multi_future.hpp.

◆ MultiFuture() [2/3]

MultiFuture ( MultiFuture< T > const &  )
delete

◆ MultiFuture() [3/3]

MultiFuture ( MultiFuture< T > &&  )
default

◆ ~MultiFuture()

~MultiFuture ( )
default

Member Function Documentation

◆ get() [1/2]

void get ( )
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.

◆ get() [2/2]

std::vector<T> get ( )
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.

◆ operator=() [1/2]

MultiFuture& operator= ( MultiFuture< T > &&  )
default

◆ operator=() [2/2]

MultiFuture& operator= ( MultiFuture< T > const &  )
delete

◆ operator[]() [1/2]

ProactiveFuture<T>& operator[] ( size_t  i)
inline

Get a reference to one of the stored futures.

Definition at line 189 of file multi_future.hpp.

◆ operator[]() [2/2]

ProactiveFuture<T> const& operator[] ( size_t  i) const
inline

Get a const reference to one of the stored futures.

Definition at line 197 of file multi_future.hpp.

◆ push_back()

void push_back ( ProactiveFuture< T >  future)
inline

Append a future.

Definition at line 114 of file multi_future.hpp.

◆ size()

size_t size ( ) const
inline

Get the number of stored futures.

Definition at line 205 of file multi_future.hpp.

◆ valid()

bool valid ( ) const
inline

Return whether all stored futures are valid.

Definition at line 122 of file multi_future.hpp.

◆ wait()

void wait ( ) const
inline

Wait for all the stored futures.

Definition at line 179 of file multi_future.hpp.


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