Import std.concurrent.cancellation
std.concurrent.cancellation
Cancellation: a flag that code sets to stop work under way, on any thread. The blocking calls that take one give up once it's set, before or while they wait, and throw a CancelledError: a Semaphore's Acquire, a WaitGroup's Wait, Sleep, and a Channel's Receive and Send. Work that doesn't wait asks IsCancelled, or calls Check, now and then, and Async code awaits its Task.
std/concurrent/cancellation.fb
Types
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.
std/concurrent/cancellation.fb, line 24
-
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.
Functions
Sleep
function
Public Function Sleep(time: Duration, cancel: Cancellation) Throws CancelledError
Sleeps for time unless the cancellation is cancelled first, or is already, which throws a
CancelledError. A time of 0 or less doesn't sleep.
Report an issue with this page or with FutureBlitz on GitHub.