hpx/async_combinators/when_any.hpp#

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

namespace hpx

Functions

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

The function when_any is a non-deterministic choice operator. It OR-composes all future objects given 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 of 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>> when_any(Range &values)#

The function when_any is a non-deterministic choice operator. It OR-composes all future objects given 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 of 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>...>>> when_any(T&&... futures)#

The function when_any is a non-deterministic choice operator. It OR-composes all future objects given 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.

template<typename InputIter, typename Container = vector<future<typename std::iterator_traits<InputIter>::value_type>>>
future<when_any_result<Container>> when_any_n(InputIter first, std::size_t count)#

The function when_any_n is a non-deterministic choice operator. It OR-composes all future objects given and returns a new future object representing the same list of futures after one future of that list finishes execution.

Note

None of the futures in the input sequence are invalidated.

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

  • count – [in] The number of elements in the sequence starting at first.

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 of the same type. The order of the futures in the output container will be the same as given by the input iterator.

template<typename Sequence>
struct when_any_result#
#include <when_any.hpp>

Result type for when_any, contains a sequence of futures and an index pointing to a ready future.

Public Members

std::size_t index#

The index of a future which has become ready.

Sequence futures#

The sequence of futures as passed to hpx::when_any