Skip to content
FutureBlitz

    Install

    Import std.concurrent.cancellation

    Cancellation

    std.concurrent.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

    • Public New() constructor #

      A new Cancellation, which isn't set.

    • Public Method Cancel() method #

      Sets it, which wakes the calls that wait with it, on every thread, and finishes its Tasks. Cancelling it again does nothing.

    • Public Property IsCancelled: Bool property #

      Whether it's cancelled.

    • Public Method Check() Throws CancelledError method #

      Throws a CancelledError once it's cancelled, for work to call between its steps.

    • Public Property Task: Task property #

      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.