hpx::when_all

hpx::when_all#

Defined in header hpx/future.hpp.

See Public API for a list of names and headers that are part of the public HPX API.

template<typename InputIter, typename Container = vector<future<typename std::iterator_traits<InputIter>::value_type>>>
hpx::future<Container> hpx::when_all(InputIter first, InputIter last)#

function when_all creates a future object that becomes ready when all elements in a set of future and shared_future objects become ready. It is an operator allowing to join on the result of all given futures. It AND-composes all given future objects and returns a new future object representing the same list of futures after they finished executing.

Note

Calling this version of when_all where first == last, returns a future with an empty container that is immediately ready. 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.

Parameters:
  • first – [in] The iterator pointing to the first element of a sequence of future or shared_future objects for which when_all should wait.

  • last – [in] The iterator pointing to the last element of a sequence of future or shared_future objects for which when_all should wait.

Returns:

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

  • future<Container<future<R>>>: If the input cardinality is unknown at compile time and the futures are all have the same type. The order of the futures in the output container will be the same as given by the input iterator.

template<typename Range>
hpx::future<Range> hpx::when_all(Range &&values)#

function when_all creates a future object that becomes ready when all elements in a set of future and shared_future objects become ready. It is an operator allowing to join on the result of all given futures. It AND-composes all given future objects and returns a new future object representing the same list of futures after they finished executing.

Note

Calling this version of when_all where the input container is empty, returns a future with an empty container that is immediately ready. 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.

Parameters:

values – [in] A range holding an arbitrary amount of future or shared_future objects for which when_all should wait.

Returns:

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

  • future<Container<future<R>>>: If the input cardinality is unknown at compile time and the futures are all have the same type.

template<typename ...T>
hpx::future<hpx::tuple<hpx::future<T>...>> hpx::when_all(T&&... futures)#

function when_all creates a future object that becomes ready when all elements in a set of future and shared_future objects become ready. It is an operator allowing to join on the result of all given futures. It AND-composes all given future objects and returns a new future object representing the same list of futures after they finished executing.

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.

Parameters:

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

Returns:

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.