Skip to content
FutureBlitz

    Install

    Import std.concurrent.cancellation

    Sleep

    std.concurrent.cancellation

    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.

    Examples

    Local cancel = Cancellation()
    cancel.Cancel()
    // A cancelled Cancellation stops the Sleep before it starts.
    Expect(ExpectThrows<CancelledError>(Sleep(10.Seconds, cancel)) != Null)

    std/concurrent/cancellation.fb, line 93

    Report an issue with this page or with FutureBlitz on GitHub.