Import std.concurrent.cancellation
Cancellation
class
Public Shared Class Cancellation
A flag that, once Cancel sets it, stops the work it's given to. It's a Shared Class, so a Const or a parameter shares one with the work that Spawn and Thread.Start run, and any thread can cancel it. Once it's set, it stays set.
Examples
Local cancel = Cancellation()
Expect(!cancel.IsCancelled)
cancel.Cancel()
Expect(cancel.IsCancelled)
Expect(ExpectThrows<CancelledError>(cancel.Check()) != Null)std/concurrent/cancellation.fb, line 36
-
A new Cancellation, which isn't set.
-
Sets it, which wakes the calls that wait with it, on every thread, and finishes its Tasks. Cancelling it again does nothing.
-
Whether it's cancelled.
-
Throws a CancelledError once it's cancelled, for work to call between its steps.
-
A Task that's done once it's cancelled, which an Await waits for, beside other Tasks, as with WhenAny. Each one it gives is a new Task.
Report an issue with this page or with FutureBlitz on GitHub.