Affected subclause: [thread.barrier]
Change: In this revision of C++,
it is implementation-defined whether a barrier's phase completion step runs
if no thread calls
wait. Previously the phase completion step was guaranteed to run on the last thread that calls
arrive or
arrive_and_drop during the phase
. In this revision of C++,
it can run on any of the threads that arrived or waited at the barrier
during the phase
. Rationale: Correct contradictory wording and
improve implementation flexibility for performance
. Effect on original feature: Valid C++ 2020 code using a barrier might have
different semantics in this revision of C++
if it depends on a completion function's side effects occurring exactly once,
on a specific thread running the phase completion step, or
on a completion function's side effects occurring
without
wait having been called
. For example:
auto b0 = std::barrier(1);
b0.arrive();
b0.arrive();
int data = 0;
auto b1 = std::barrier(1, [&] { data++; });
b1.arrive();
assert(data == 1);
b1.arrive();