Class Barrier

Class Documentation

class switchml::Barrier

A class that implements a simple thread barrier. Simply create an instance that is visible to using threads then from each thread call the wait function.

Public Functions

Barrier(const int num_participants)

Construct a new Barrier object.

Parameters

num_participants[in] Number of threads that will use the barrier

~Barrier()

Call Destroy() just in case it hasn’t been called and some threads are waiting.

See

Destroy()

Barrier(Barrier const&) = delete
void operator=(Barrier const&) = delete
Barrier(Barrier&&) = default
Barrier &operator=(Barrier&&) = default
void Wait()

Block the thread until all other participating threads arrive at the barrier.

void Destroy()

Wakeup all waiting threads and make this barrier unusable.