Import std.concurrent.locks
Barrier
class
Public Shared Class Barrier
Where a number of threads meet, round after round: each one's Wait returns once they've all come, which starts the next round.
Examples
Global lasts = Atomic<Int>(0)
Const meet = Barrier(2)
Function Arrive()
If meet.Wait() Then lasts.Add(1)
End Function
Local other = Spawn(Arrive)
Arrive()
other.Wait()
// One of the two is the round's last.
Expect(lasts.Load() == 1)std/concurrent/locks.fb, line 124
-
A Barrier that
countthreads meet at each round. Panics unless that's 1 or more. -
Waits until the round's last thread comes, and then they all go on. Gives True to that last one, and False to the others, so one of them can do what's done once a round.
-
How many threads meet at it each round.
Report an issue with this page or with FutureBlitz on GitHub.