HPX - High Performance ParalleX


Function template when_all



// In header: <hpx/lcos/when_all.hpp>

template<typename... T> 
  future< tuple< future< T >...> > when_all(T &&... futures);


The function when_all is an operator allowing to join on the result of all given futures. It AND-composes all future objects given and returns a new future object representing the same list of futures after they finished executing.

[Note] Note

Each future and shared_future is waited upon and then copied into the collection of the output (returned) future, maintaining the order of the futures in the input collection. The future returned by when_all will not throw an exception, but the futures held in the output collection may.



[in] An arbitrary number of future or shared_future objects, possibly holding different types for which when_all should wait.


Returns a future holding the same list of futures as has been passed to when_all.

  • future<tuple<future<T0>, future<T1>, future<T2>...>>: If inputs are fixed in number and are of heterogeneous types. The inputs can be any arbitrary number of future objects.

  • future<tuple<>> if when_all is called with zero arguments. The returned future will be initially ready.