Files
2025-10-25 03:02:53 +03:00

1.7 KiB

[diff.cpp20.thread]

Annex C (informative) Compatibility [diff]

C.2 C++ and ISO C++ 2020 [diff.cpp20]

C.2.13 [thread]: concurrency support library [diff.cpp20.thread]

1

#

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.

[Example 1: auto b0 = std::barrier(1); b0.arrive(); b0.arrive(); // implementation-defined; previously well-definedint data = 0;auto b1 = std::barrier(1, [&] { data++; }); b1.arrive(); assert(data == 1); // implementation-defined; previously well-defined b1.arrive(); // implementation-defined; previously well-defined — end example]