RobWorkProject  23.9.11-
Public Member Functions | List of all members
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. More...
 
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. More...
 
std::future< T > & operator[] (const size_t i)
 Get a reference to one of the futures stored in this multi_future object. More...
 
void push_back (std::future< T > future)
 Append a future to this multi_future object. More...
 
size_t size () const
 Get the number of futures stored in this multi_future object. More...
 
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()

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()

std::conditional_t<std::is_void_v<T>, void, std::vector<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[]()

std::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()

void push_back ( std::future< T >  future)
inline

Append a future to this multi_future object.

Parameters
futureThe future to append.

◆ size()

size_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: