Struct Barrier

A cross fibers synchronization point.

struct Barrier ;

Barrier has several deployment methods. The basic idea is to divide the fibers into those who need to "check in", and those that wait for the check in counter to reach the correct amount.

The most common use case is waiting for launched fibers to finish. To facilitate this mode, the following code structure is used:

void fiberDlg() {
  scope(exit) barrier.markDone();
  ...
}
...
theReactor.spawnFiber!fiberDlg();
barrier.addWaiter();
...
barrier.waitAll();

Properties

NameTypeDescription
hasWaiters[get] boolReport whether there are any fibers we might be waiting for
numWaiters[get] const(uint)Report how many fibers we are waiting for

Methods

NameDescription
addWaiter Increase number of expected completions by one.
markDone Increase number of completions by one.
markDoneAndWaitAll Mark one completion and wait for all other completions to happen.
waitAll Wait for all completion events to happen.