This module contains the implementation of Std.CancellationToken. Std.CancellationToken provides a
cancellation primitive for signaling cancellation between tasks or threads. It supports both synchronous
and asynchronous waiting, and is useful for cases where you want to notify one or more waiters
that a cancellation has occurred.
Reasons for cancellation.
- deadline : CancellationReason
Cancelled due to a deadline or timeout
- shutdown : CancellationReason
Cancelled due to shutdown
- cancel : CancellationReason
Explicitly cancelled
- custom (msg : String) : CancellationReason
Custom cancellation reason
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Std.instBEqCancellationReason.beq Std.CancellationReason.deadline Std.CancellationReason.deadline = true
- Std.instBEqCancellationReason.beq Std.CancellationReason.shutdown Std.CancellationReason.shutdown = true
- Std.instBEqCancellationReason.beq Std.CancellationReason.cancel Std.CancellationReason.cancel = true
- Std.instBEqCancellationReason.beq (Std.CancellationReason.custom a) (Std.CancellationReason.custom b) = (a == b)
- Std.instBEqCancellationReason.beq x✝¹ x✝ = false
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
A cancellation token is a synchronization primitive that allows multiple consumers to wait until cancellation is requested.
Instances For
Creates a new cancellation token.
Equations
- Std.CancellationToken.new = do let __do_lift ← Std.Mutex.new { reason := none, consumers := ∅ } pure { state := __do_lift }
Instances For
Cancels the token with the given reason, notifying all currently waiting consumers. Once cancelled, the token remains cancelled.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if the token is cancelled.
Equations
- x.isCancelled = (Std.CancellationToken.state✝ x).atomically do let st ← get pure (Std.CancellationToken.State.reason✝ st).isSome
Instances For
Gets the cancellation reason if the token is cancelled.
Equations
- x.getCancellationReason = (Std.CancellationToken.state✝ x).atomically do let st ← get pure (Std.CancellationToken.State.reason✝ st)
Instances For
Waits for cancellation. Returns a task that completes when cancelled.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Creates a selector that waits for cancellation.
Equations
- One or more equations did not get rendered due to their size.