hpx/async_combinators/when_each.hpp#

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

namespace hpx

Functions

template<typename F, typename Future>
future<void> when_each(F &&f, std::vector<Future> &&futures)#

The function when_each is an operator allowing to join on the results of all given futures. It AND-composes all future objects given and returns a new future object representing the event of all those futures having finished executing. It also calls the supplied callback for each of the futures which becomes ready.

Note

This function consumes the futures as they are passed on to the supplied function. The callback should take one or two parameters, namely either a future to be processed or a type that std::size_t is implicitly convertible to as the first parameter and the future as the second parameter. The first parameter will correspond to the index of the current future in the collection.

Parameters
  • f – The function which will be called for each of the input futures once the future has become ready.

  • futures – A vector holding an arbitrary amount of future or shared_future objects for which wait_each should wait.

Returns

Returns a future representing the event of all input futures being ready.

template<typename F, typename Iterator>
future<Iterator> when_each(F &&f, Iterator begin, Iterator end)#

The function when_each is an operator allowing to join on the results of all given futures. It AND-composes all future objects given and returns a new future object representing the event of all those futures having finished executing. It also calls the supplied callback for each of the futures which becomes ready.

Note

This function consumes the futures as they are passed on to the supplied function. The callback should take one or two parameters, namely either a future to be processed or a type that std::size_t is implicitly convertible to as the first parameter and the future as the second parameter. The first parameter will correspond to the index of the current future in the collection.

Parameters
  • f – The function which will be called for each of the input futures once the future has become ready.

  • begin – The iterator pointing to the first element of a sequence of future or shared_future objects for which wait_each should wait.

  • end – The iterator pointing to the last element of a sequence of future or shared_future objects for which wait_each should wait.

Returns

Returns a future representing the event of all input futures being ready.

template<typename F, typename ...Ts>
future<void> when_each(F &&f, Ts&&... futures)#

The function when_each is an operator allowing to join on the results of all given futures. It AND-composes all future objects given and returns a new future object representing the event of all those futures having finished executing. It also calls the supplied callback for each of the futures which becomes ready.

Note

This function consumes the futures as they are passed on to the supplied function. The callback should take one or two parameters, namely either a future to be processed or a type that std::size_t is implicitly convertible to as the first parameter and the future as the second parameter. The first parameter will correspond to the index of the current future in the collection.

Parameters
  • f – The function which will be called for each of the input futures once the future has become ready.

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

Returns

Returns a future representing the event of all input futures being ready.

template<typename F, typename Iterator>
future<Iterator> when_each_n(F &&f, Iterator begin, std::size_t count)#

The function when_each is an operator allowing to join on the results of all given futures. It AND-composes all future objects given and returns a new future object representing the event of all those futures having finished executing. It also calls the supplied callback for each of the futures which becomes ready.

Note

This function consumes the futures as they are passed on to the supplied function. The callback should take one or two parameters, namely either a future to be processed or a type that std::size_t is implicitly convertible to as the first parameter and the future as the second parameter. The first parameter will correspond to the index of the current future in the collection.

Parameters
  • f – The function which will be called for each of the input futures once the future has become ready.

  • begin – The iterator pointing to the first element of a sequence of future or shared_future objects for which wait_each_n should wait.

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

Returns

Returns a future holding the iterator pointing to the first element after the last one.