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

Public Member Functions | |
| barrier (std::ptrdiff_t count, CompletionFunction completion=[](){}) | |
| Constructs a barrier for the given number of threads. | |
| void | arrive_and_wait () |
| Arrives at the barrier and blocks until all threads arrive. | |
| void | arrive_and_drop () |
| Decrements the counter without blocking. | |
Private Attributes | |
| std::mutex | mutex_ |
| std::condition_variable | cv_ |
| std::ptrdiff_t | threshold_ |
| std::ptrdiff_t | count_ |
| std::size_t | generation_ |
| CompletionFunction | completion_ |
C++17-compatible barrier implementation.
A reusable thread coordination mechanism that blocks a set of threads until all threads have arrived at the barrier.
| CompletionFunction | A callable invoked when all threads arrive |
Definition at line 101 of file synchronization.h.
|
inlineexplicit |
Constructs a barrier for the given number of threads.
| count | The number of threads to synchronize (must be > 0) |
| completion | Optional function called when all threads arrive |
Definition at line 108 of file synchronization.h.
|
inline |
Decrements the counter without blocking.
Equivalent to arrive_and_drop() in C++20. This thread will not participate in future barrier phases.
Definition at line 152 of file synchronization.h.
References kcenon::thread::barrier< CompletionFunction >::arrive_and_wait(), kcenon::thread::barrier< CompletionFunction >::mutex_, and kcenon::thread::barrier< CompletionFunction >::threshold_.

|
inline |
Arrives at the barrier and blocks until all threads arrive.
When the last thread arrives:
Definition at line 123 of file synchronization.h.
References kcenon::thread::barrier< CompletionFunction >::completion_, kcenon::thread::barrier< CompletionFunction >::count_, kcenon::thread::barrier< CompletionFunction >::cv_, kcenon::thread::barrier< CompletionFunction >::generation_, kcenon::thread::barrier< CompletionFunction >::mutex_, and kcenon::thread::barrier< CompletionFunction >::threshold_.
Referenced by kcenon::thread::barrier< CompletionFunction >::arrive_and_drop().

|
private |
Definition at line 164 of file synchronization.h.
Referenced by kcenon::thread::barrier< CompletionFunction >::arrive_and_wait().
|
private |
Definition at line 162 of file synchronization.h.
Referenced by kcenon::thread::barrier< CompletionFunction >::arrive_and_wait().
|
mutableprivate |
Definition at line 160 of file synchronization.h.
Referenced by kcenon::thread::barrier< CompletionFunction >::arrive_and_wait().
|
private |
Definition at line 163 of file synchronization.h.
Referenced by kcenon::thread::barrier< CompletionFunction >::arrive_and_wait().
|
mutableprivate |
Definition at line 159 of file synchronization.h.
Referenced by kcenon::thread::barrier< CompletionFunction >::arrive_and_drop(), and kcenon::thread::barrier< CompletionFunction >::arrive_and_wait().
|
private |
Definition at line 161 of file synchronization.h.
Referenced by kcenon::thread::barrier< CompletionFunction >::arrive_and_drop(), and kcenon::thread::barrier< CompletionFunction >::arrive_and_wait().