HPX - High Performance ParalleX

PrevUpHomeNext

Function template when_some_n

hpx::when_some_n

Synopsis

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


template<typename InputIter> 
  future< when_some_result< vector< future< typename std::iterator_traits< InputIter >::value_type > > > > 
  when_some_n(std::size_t n, Iterator first, std::size_t count, 
              error_code & ec = throws);

Description

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] Note

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

[Note] 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 vector 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:

count

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

ec

[in,out] this represents the error status on exit, if this is pre-initialized to hpx::throws the function will throw on error instead.

first

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

n

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

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<vector<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 vector will be the same as given by the input iterator.


PrevUpHomeNext