hpx/async_combinators/when_some.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_some_result<Container>> when_some(std::size_t n, Iterator first, Iterator last)#

The function when_some 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 n of them finished executing.

Note

The future returned by the function when_some becomes ready when at least n argument futures have become ready.

Note

Calling this version of when_some 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_some will not throw an exception, but the futures held in the output collection may.

Parameters
  • n – [in] The number of futures out of the arguments which have to become ready in order for the returned future to get ready.

  • 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 when_some_result holding the same list of futures as has been passed to when_some and indices pointing to ready futures.

  • future<when_some_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_some_result<Range>> when_some(std::size_t n, Range &&futures)#

The function when_some 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 n of them finished executing.

Note

The future returned by the function when_some becomes ready when at least n argument futures have become ready.

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_some will not throw an exception, but the futures held in the output collection may.

Parameters
  • n – [in] The number of futures out of the arguments which have to become ready in order for the returned future to get ready.

  • futures – [in] A container holding an arbitrary amount of future or shared_future objects for which when_some should wait.

Returns

Returns a when_some_result holding the same list of futures as has been passed to when_some and indices pointing to ready futures.

  • future<when_some_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 ...Ts>
future<when_some_result<tuple<future<T>...>>> when_some(std::size_t n, Ts&&... futures)#

The function when_some 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 n of them finished executing.

Note

The future returned by the function when_some becomes ready when at least n argument futures have become ready.

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_some will not throw an exception, but the futures held in the output collection may.

Parameters
  • n – [in] The number of futures out of the arguments which have to become ready in order for the returned future to get ready.

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

Returns

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

  • future<when_some_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_some_result<tuple<>>> if when_some 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_some_result<Container>> when_some_n(std::size_t n, Iterator first, std::size_t count)#

The function when_some_n 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 n of them finished executing.

Note

The future returned by the function when_some_n becomes ready when at least n argument futures have become ready.

Note

Calling this version of when_some_n where count == 0, returns a future with the same elements as the arguments that is immediately ready. Possibly none of the futures in that container are 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_some_n will not throw an exception, but the futures held in the output collection may.

Parameters
  • n – [in] The number of futures out of the arguments which have to become ready in order for the returned future to get ready.

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

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

Returns

Returns a when_some_result holding the same list of futures as has been passed to when_some and indices pointing to ready futures.

  • future<when_some_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_some_result#
#include <when_some.hpp>

Result type for when_some, contains a sequence of futures and indices pointing to ready futures.

Public Members

std::vector<std::size_t> indices#

List of indices of futures that have become ready.

Sequence futures#

The sequence of futures as passed to hpx::when_some.