Documentation Home >> Headers >> <jss/experimental_barrier.hpp> Header >> std::experimental::flex_barrier >> std::experimental::flex_barrier constructor with a completion function

Construct a std::experimental::flex_barrier with N participating threads and a completion function.

The completion function allows additional synchronization or notification to be done when all participating threads have arrived at the barrier, and allows the number of participating threads to be changed.

When all participating threads have arrived at the barrier, the completion function is called with the current number of participating threads (which may already have been reduced due to calls to std::experimental::flex_barrier::arrive_and_drop).

If the completion function returns less than 0 then the number of participating threads is unchanged, otherwise the number of participating threads in the next cycle is set to the returned value.

template<typename CompletionFunc>
explicit flex_barrier(ptrdiff_t num_threads,CompletionFunc comp_func):

Preconditions:

The statement ptrdiff_t x=comp_func(num_threads) shall be well-formed and not-throw any exceptions.

Effects:

The newly-constructed flex_barrier has num_threads participating threads. The completion function is initialized as-if CompletionFunc f(std::move(comp_func)).

Header

#include <experimental/barrier>

See Also