This module provides a tree-structured cancellation context called CancellationToken where cancelling a parent
automatically cancels all child contexts.
A cancellation context that allows multiple consumers to wait until cancellation is requested. Forms a tree structure where cancelling a parent cancels all children.
- token : CancellationToken
- id : UInt64
Instances For
Creates a new root cancellation context.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Forks a child context from a parent. If the parent is already cancelled, returns the parent context. Otherwise, creates a new child that will be cancelled when the parent is cancelled.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cancels this context and all child contexts with the given reason.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if the context is cancelled.
Equations
- x.isCancelled = x.token.isCancelled
Instances For
Returns the cancellation reason if the context is cancelled.
Equations
Instances For
Waits for cancellation. Returns a task that completes when the context is cancelled.
Instances For
Creates a selector that waits for cancellation.
Equations
- x.doneSelector = x.token.selector
Instances For
Counts the number of alive (non-cancelled) tokens in the context tree, including this context and all its descendants.
Equations
- x.countAliveTokens = x.state.atomically do let st ← get pure (Std.CancellationContext.countAliveTokensRec✝ st x.id)