Import std.concurrent.locks
WaitGroup
class
Public Shared Class WaitGroup
A count of the work under way, which Wait waits to see at 0: Add counts work before it starts, and Done says that some is done.
Examples
Global finished = Atomic<Int>(0)
Const work = WaitGroup()
Function Step()
finished.Add(1)
work.Done()
End Function
work.Add(3)
For i = 1 To 3
Spawn(Step)
End For
work.Wait()
Expect(finished.Load() == 3)std/concurrent/locks.fb, line 172
-
A WaitGroup counting 0.
-
Adds
count, which can be negative, to the work it counts, and wakes the threads waiting once that's 0. Panics when it would take that below 0, or past what an Int holds. -
Takes 1 from the count. Panics when it's 0, since Done would be once more than Add counted.
-
Waits until the count is 0, which it may be already.
-
Waits until the count is 0 unless the cancellation is cancelled first, or is already, which throws a CancelledError.
-
The count now, which other threads may change at any time.
Report an issue with this page or with FutureBlitz on GitHub.