ORIGINAL
|
Synchronization point for multiple threads. More...
#include <syncPoint.h>
Public Member Functions | |
syncPoint () | |
Constructs a disabled synchronization point. | |
syncPoint (u_integer max_arrived, const std::function< void()> &func={}) | |
Constructs a synchronization point with specified thread count. | |
void | arrive () |
Arrive at the synchronization point. | |
u_integer | maxArrived () const |
Get the maximum number of threads required for synchronization. | |
u_integer | currentArrived () const |
Get the current number of arrived threads. | |
Synchronization point for multiple threads.
A synchronization primitive that allows multiple threads to wait for each other at a specific point in execution. Threads call arrive() to indicate they have reached the synchronization point, and the last arriving thread triggers the completion function and releases all waiting threads.
Features:
|
inline |
|
inlineexplicit |
Constructs a synchronization point with specified thread count.
max_arrived | Number of threads required to trigger synchronization |
func | Completion function called by the last arriving thread |
The completion function is executed by the last thread that calls arrive(), before releasing all waiting threads. If the function throws an exception, it will be propagated to all threads waiting at the barrier.
|
inline |
Arrive at the synchronization point.
Blocks the calling thread until the required number of threads (max_arrived) have called arrive(). The last thread to arrive will execute the completion function and release all waiting threads.
std::exception | If the completion function throws an exception, all waiting threads will rethrow the same exception. |
|
inline |
Get the current number of arrived threads.
This value is reset to 0 when the required number of threads arrive and a new synchronization round begins.
|
inline |
Get the maximum number of threads required for synchronization.