hpx::when_any

hpx::when_any#

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>>>
future<when_any_result<Container>> hpx::when_any(InputIter first, InputIter last)#

function when_any creates a future object that becomes when at least one element in a set of future and shared_future objects becomes ready. It is a non-deterministic choice operator. It OR-composes all given future objects and returns a new future object representing the same list of futures after one future of that list finishes execution.

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

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

Returns:

Returns a when_any_result holding the same list of futures as has been passed to when_any and an index pointing to a ready future.

  • future<when_any_result<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>
future<when_any_result<Range>> hpx::when_any(Range &values)#

function when_any creates a future object that becomes when at least one element in a set of future and shared_future objects becomes ready. It is a non-deterministic choice operator. It OR-composes all given future objects and returns a new future object representing the same list of futures after one future of that list finishes execution.

Parameters:

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

Returns:

Returns a when_any_result holding the same list of futures as has been passed to when_any and an index pointing to a ready future.

  • future<when_any_result<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 ...T>
future<when_any_result<tuple<future<T>...>>> hpx::when_any(T&&... futures)#

function when_any creates a future object that becomes when at least one element in a set of future and shared_future objects becomes ready. It is a non-deterministic choice operator. It OR-composes all given future objects and returns a new future object representing the same list of futures after one future of that list finishes execution.

Parameters:

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

Returns:

Returns a when_any_result holding the same list of futures as has been passed to when_any and an index pointing to a ready future.

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

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