Import std.concurrent.locks
Once
class
Public Shared Class Once
Work that runs one time: the first Do runs it, and every other, at once or after, on any thread, returns once it has run.
Examples
Global runs = Atomic<Int>(0)
Const setup = Once()
Function CountRun()
runs.Add(1)
End Function
Parallel For i = 0 Until 8
setup.Do(CountRun)
End For
Expect(runs.Load() == 1 && setup.IsDone)std/concurrent/locks.fb, line 241
-
A new Once, whose work hasn't run.
-
Runs
work, unless a Do has, waiting while another thread's Do runs it. Panics in a Do that theworkitself calls, which would wait for itself forever. -
Whether the work has run.
Report an issue with this page or with FutureBlitz on GitHub.