Barrier

class Barrier

Public Functions

Barrier(dragonChannelDescr_t *barrier_channel, action_func action)

Construct a Barrier object from a Barrier channel.

Given a channel that was created as a barrier channel, construct a C++ Barrier object over it. Typically this constructor would only be used if there was a need to customize the channel in some way outside of the Barrier support.

Parameters:

barrier_channel – Is a channel descriptor for a barrier channel.

Barrier(const char *serialized_barrier, action_func action)

Attach to an existing Barrier object. Given a serialized descriptor for a Barrier, create a Barrier object over it. The Barrier would have been created elsewhere, either in Python or C++. If created in Python, the Python code controls the lifetime of the Barrier. See the Dragon Native Python Barrier documentation for a description of how its lifetime is managed.

Parameters:

serialized_sem – A serialized descriptor of the barrier object.

~Barrier()

Destructor for a Barrier.

Calling delete on a Barrier pointer or allowing a stack allocated Barrier to fall out of scope calls this destructor which automatically takes care of any cleanup.

size_t wait(timespec_t *timeout = nullptr)

Wait on the barrier.

Wait on the barrier until all parties are waiting or the timeout expires.

Returns:

an unique integer ranging from 0 to number of parties-1 for the barrier.

void reset()

Reset the barrier.

Set the barrier to the empty state. Any waiting processes receive the BrokenBarrierError.

void abort()

abort the barrier.

After calling this the barrier is broken. Any waiters that are in wait state will receive BrokenBarrierError.

size_t parties()

Return the specified number of parties to the barrier.

Returns:

the number of parties of the barrier.

size_t n_waiting()

Return the number of parties currently in the barrier.

bool broken()

Return whether barrier is broken.

Returns:

true or false

const char *serialize()

Returns a serialized representation of the barrier that may be shared with other processes in a parallel program.

Returns:

A string representing the serialized Barrier which may be shared with other processes.