ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
original::syncPoint Class Reference

Synchronization point for multiple threads. More...

#include <syncPoint.h>

Collaboration diagram for original::syncPoint:
Collaboration graph

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.
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ syncPoint() [1/2]

original::syncPoint::syncPoint ( )
inline

Constructs a disabled synchronization point.

Creates a syncPoint with max_arrived = 0. arrive() calls on this instance will return immediately without any synchronization.

◆ syncPoint() [2/2]

original::syncPoint::syncPoint ( u_integer  max_arrived,
const std::function< void()> &  func = {} 
)
inlineexplicit

Constructs a synchronization point with specified thread count.

Parameters
max_arrivedNumber of threads required to trigger synchronization
funcCompletion 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.

Member Function Documentation

◆ arrive()

void original::syncPoint::arrive ( )
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.

Exceptions
std::exceptionIf the completion function throws an exception, all waiting threads will rethrow the same exception.

◆ currentArrived()

original::u_integer original::syncPoint::currentArrived ( ) const
inline

Get the current number of arrived threads.

Returns
Number of threads that have arrived in the current round

This value is reset to 0 when the required number of threads arrive and a new synchronization round begins.

◆ maxArrived()

original::u_integer original::syncPoint::maxArrived ( ) const
inline

Get the maximum number of threads required for synchronization.

Returns
Maximum number of threads that must arrive

The documentation for this class was generated from the following file: