Documentation

Std.Async.Watchdog

This module provides Watchdog, which enforces deadlines on a sequence of waits with a single background timer.

Enforces deadlines on a sequence of waits with a single background timer. A wait starts with arm and ends with disarm; when one outlives its deadline, the watchdog cancels its context with .deadline and stops. The context is never cancelled before the deadline.

Waits whose deadlines keep moving later, such as idle timeouts, cost no timer operation each: only a deadline earlier than the one the timer is set for restarts it.

The context is cancelled from a task on the shared task pool, so while every worker is busy, a late wait may stay uncancelled until one is free. disarm reports a late wait regardless.

The watchdog and its timer stay alive until the context is cancelled, so the context should be cancelled once the watchdog is no longer needed.

Instances For

    Creates a watchdog that cancels ctx with .deadline when a wait outlives its deadline.

    The watchdog and its timer stay alive until ctx is cancelled, so ctx should be cancelled once the watchdog is no longer needed.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Starts a wait that must end by deadline, a value of IO.monoMsNow. Arming again before disarm replaces the deadline. Does nothing once the watchdog has fired.

      Equations
      Instances For
        def Std.Async.Watchdog.armAfter {α : Type u_1} (wd : Watchdog) (task : Task α) (timeout : Time.Millisecond.Offset) :

        Starts a wait that must end within timeout of task finishing, and that does not time out before then: a deadline set for the current wait is dropped. If the wait ends, or is armed again, before task finishes, nothing is armed. Does nothing once the watchdog has fired.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Starts a wait that must end within timeout. Arming again before disarm replaces the deadline. Does nothing once the watchdog has fired.

          Equations
          Instances For

            Ends the current wait. Returns true if a wait outlived its deadline, in which case the context is cancelled with .deadline. A wait whose context was cancelled for another reason first is not reported.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Returns true if a wait outlived its deadline and its context was cancelled with .deadline. If the watchdog has marked a wait as late but not cancelled the context yet, this cancels it first.

              Equations
              Instances For