std::experimental::latch

From cppreference.com
 
 
Experimental
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
 
 
 
Defined in header <experimental/latch>
class latch;
(concurrency TS)

The latch class is a downward counter of type ptrdiff_t which can be used to synchronize threads. The value of the counter is initialized on creation. Threads may block on the latch until the counter is decremented to zero. There is no possibility to increase or reset the counter, which makes the latch a single-use barrier.

Unlike std::experimental::barrier, std::experimental::latch can be decremented by a participating thread more than once.

Member functions

constructs a latch
(public member function)
destroys the latch
(public member function)
operator=
[deleted]
not copy-assignable
(public member function)
decrements the counter by 1 and blocks until it reaches zero
(public member function)
decrements the counter in a non-blocking manner
(public member function)
tests if the internal counter equals zero
(public member function)
blocks until the counter reaches zero
(public member function)