|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
C++17-compatible latch implementation. More...
#include <synchronization.h>

Public Member Functions | |
| latch (std::ptrdiff_t count) | |
| Constructs a latch with the given count. | |
| void | count_down (std::ptrdiff_t n=1) |
| Decrements the counter in a non-blocking manner. | |
| bool | try_wait () const noexcept |
| Tests if the internal counter equals zero. | |
| void | wait () const |
| Blocks until the counter reaches zero. | |
| void | arrive_and_wait (std::ptrdiff_t n=1) |
| Decrements the counter and blocks until it reaches zero. | |
Private Attributes | |
| std::mutex | mutex_ |
| std::condition_variable | cv_ |
| std::ptrdiff_t | count_ |
C++17-compatible latch implementation.
A downward counter 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.
Definition at line 39 of file synchronization.h.
|
inlineexplicit |
Constructs a latch with the given count.
| count | The initial value of the counter (must be >= 0) |
Definition at line 45 of file synchronization.h.
|
inline |
Decrements the counter and blocks until it reaches zero.
| n | The value to subtract from the counter (default: 1) |
Definition at line 81 of file synchronization.h.
References count_down(), and wait().

|
inline |
Decrements the counter in a non-blocking manner.
| n | The value to subtract from the counter (default: 1) |
Definition at line 52 of file synchronization.h.
References count_, cv_, and mutex_.
Referenced by arrive_and_wait().

|
inlinenoexcept |
|
inline |
Blocks until the counter reaches zero.
Definition at line 72 of file synchronization.h.
References count_, cv_, and mutex_.
Referenced by arrive_and_wait().

|
private |
Definition at line 89 of file synchronization.h.
Referenced by count_down(), try_wait(), and wait().
|
mutableprivate |
Definition at line 88 of file synchronization.h.
Referenced by count_down(), and wait().
|
mutableprivate |
Definition at line 87 of file synchronization.h.
Referenced by count_down(), try_wait(), and wait().