Barrier

A cross fibers synchronization point.

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();

Members

Functions

addWaiter
void addWaiter()

Increase number of expected completions by one.

markDone
void markDone()

Increase number of completions by one.

markDoneAndWaitAll
void markDoneAndWaitAll(Timeout timeout)

Mark one completion and wait for all other completions to happen.

waitAll
void waitAll(Timeout timeout)

Wait for all completion events to happen.

Properties

hasWaiters
bool hasWaiters [@property getter]

Report whether there are any fibers we might be waiting for

numWaiters
auto numWaiters [@property getter]

Report how many fibers we are waiting for

Meta