![]() | Merged into ISO C++ The functionality described on this page was merged into the mainline ISO C++ standard as of 7/2019; seestd::barrier(since C++20) |
| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| std::future extensions | ||||
| Latches and barriers | ||||
experimental::barrier | ||||
| Atomic smart pointers | ||||
Defined in header <experimental/barrier> | ||
class barrier; | (concurrency TS) | |
The classstd::experimental::barrier provides a thread-coordination mechanism that allows a set of participating threads to block until an operation is completed. Unlikestd::experimental::latch, barriers are reusable; once the participating threads are released from a barrier's synchronization point, they can reuse the same barrier.
A barrier has a completion phase, which is executed by one of the participating threads once all threads in the set of participating threads arrive at the synchronization point. Thearrive_and_wait andarrive_and_drop callssynchronize with the start of the completion phase; the end of the completion phase synchronizes with the returns from all calls blocked by its completion.
Forstd::experimental::barrier, the completion phase is empty.std::experimental::flex_barrier allows the user to control the completion phase with a function object.
The set of participating threads for abarrier constructed fornum_threads threads is the firstnum_threads threads to arrive at its synchronization point after construction. The same set of threads (except for threads that calledarrive_and_drop()) must arrive at thebarrier each cycle.
constructs abarrier(public member function)[edit] | |
| destroys the barrier (public member function)[edit] | |
operator= [deleted] | not copy-assignable (public member function)[edit] |
| arrive at the synchronization point and block (public member function)[edit] | |
| arrive at the synchronization point and remove the current thread from the set of participating threads (public member function)[edit] |