FiberSim
Loading...
Searching...
No Matches
BS::multi_future< T > Class Template Reference

A helper class to facilitate waiting for and/or getting the results of multiple futures at once. More...

#include <BS_thread_pool.hpp>

Public Member Functions

 multi_future (const size_t num_futures_=0)
 Construct a multi_future object with the given number of futures.
 
std::conditional_t< std::is_void_v< T >, void, std::vector< T > > get ()
 Get the results from all the futures stored in this multi_future object, rethrowing any stored exceptions.
 
std::future< T > & operator[] (const size_t i)
 Get a reference to one of the futures stored in this multi_future object.
 
void push_back (std::future< T > future)
 Append a future to this multi_future object.
 
size_t size () const
 Get the number of futures stored in this multi_future object.
 
void wait () const
 Wait for all the futures stored in this multi_future object.
 

Detailed Description

template<typename T>
class BS::multi_future< T >

A helper class to facilitate waiting for and/or getting the results of multiple futures at once.

Template Parameters
TThe return type of the futures.

Constructor & Destructor Documentation

◆ multi_future()

template<typename T >
BS::multi_future< T >::multi_future ( const size_t  num_futures_ = 0)
inline

Construct a multi_future object with the given number of futures.

Parameters
num_futures_The desired number of futures to store.

Member Function Documentation

◆ get()

template<typename T >
std::conditional_t< std::is_void_v< T >, void, std::vector< T > > BS::multi_future< T >::get ( )
inline

Get the results from all the futures stored in this multi_future object, rethrowing any stored exceptions.

Returns
If the futures return void, this function returns void as well. Otherwise, it returns a vector containing the results.

◆ operator[]()

template<typename T >
std::future< T > & BS::multi_future< T >::operator[] ( const size_t  i)
inline

Get a reference to one of the futures stored in this multi_future object.

Parameters
iThe index of the desired future.
Returns
The future.

◆ push_back()

template<typename T >
void BS::multi_future< T >::push_back ( std::future< T future)
inline

Append a future to this multi_future object.

Parameters
futureThe future to append.

◆ size()

template<typename T >
size_t BS::multi_future< T >::size ( ) const
inline

Get the number of futures stored in this multi_future object.

Returns
The number of futures.

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