A folly::Future‐istic Barrier synchronization primitive.
Synopsis
Declared in <folly/futures/Barrier.h>
class Barrier;
Description
The barrier is initialized with a count N.
The first N‐1 calls to wait() return uncompleted futures.
The Nth call to wait() completes the previous N‐1 futures successfully, returns a future that is already completed successfully, and resets the barrier; the barrier may be reused immediately, as soon as at least one of the future completions has been observed.
Of these N futures, exactly one is completed with true, while the others are completed with false; it is unspecified which future completes with true. (This may be used to elect a "leader" among a group of threads.)
If the barrier is destroyed, any futures already returned by wait() will complete with an error.
Member Functions
Name |
Description |
|
Constructs a barrier that releases once |
|
Destroys the barrier, completing any outstanding futures with an error. |
Waits on the barrier, returning a future that completes when it releases. |
Created with MrDocs