Stdlibsync
barrier
import std::sync::barrier; · source
Barrier
type struct Barrier {
inner: BarrierInner*;
static new(count: u32) -> Barrier;
wait(&this) -> BarrierWaitResult;
}
A rendezvous for a fixed group of threads. Every thread calling wait() blocks until exactly count have arrived, then all proceed.
BarrierWaitResult
type struct BarrierWaitResult {
is_leader: boolean;
is_leader(&this) -> boolean;
}
wait() returns a BarrierWaitResult whose is_leader() is true on exactly one of the awakening threads. That flag is the standard way to designate one thread to do per-phase cleanup after every worker finishes a phase.
The barrier resets automatically for the next cycle. Barrier is Send + Sync unconditionally.
Trait implementations
implement trait Drop for struct Barrier