parallel-cellular-automata
Framework for building parallel cellular automata.
Public Member Functions | List of all members
ca::Barrier Class Reference

Self-resetting synchronization barrier for threads. More...

#include <barrier.hpp>

Public Member Functions

 Barrier (unsigned n)
 Construct a new Barrier object to syncronize n threads. More...
 
void wait ()
 wait for the other threads to reach the barrier.
 
void wait (std::function< void()> fun)
 wait for the other treads to reach the barrier and exec fun bebore notyfying others if you are the last thread to reach it. More...
 
void busy_wait ()
 busy wait for other threads to reach the barrier.
 
void busy_wait (std::function< void()> fun)
 busy wait for the other treads to reach the barrier and exec fun bebore notyfying others if you are the last thread to reach it. More...
 

Detailed Description

Self-resetting synchronization barrier for threads.

Note
The barrier self resets so that it can be reused.

Constructor & Destructor Documentation

◆ Barrier()

ca::Barrier::Barrier ( unsigned  n)
explicit

Construct a new Barrier object to syncronize n threads.

Parameters
nnumber of threads to syncronize.
Exceptions
invalid_argumentif n is equal to zero.

Member Function Documentation

◆ busy_wait()

void ca::Barrier::busy_wait ( std::function< void()>  fun)

busy wait for the other treads to reach the barrier and exec fun bebore notyfying others if you are the last thread to reach it.

Parameters
funfunction that the last thread to reach the barrier will execute before notifying.

◆ wait()

void ca::Barrier::wait ( std::function< void()>  fun)

wait for the other treads to reach the barrier and exec fun bebore notyfying others if you are the last thread to reach it.

Parameters
funfunction that the last thread to reach the barrier will execute before notifying.

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