A lightweight cooperative cancellation token backed by :atomics.
Summary
Functions
Marks the token cancelled. Cancelling an already cancelled token is a no-op.
Returns whether the token has been cancelled.
Returns a token that is not cancelled.
Recognizes a cancellation token at an untyped context boundary.
Types
Functions
@spec cancel(t()) :: :ok
Marks the token cancelled. Cancelling an already cancelled token is a no-op.
Returns whether the token has been cancelled.
A handler finds its request's token in the cancellation field of
Snodo.Context when a transport runs the request through
Snodo.Server.Executor. The field is nil for direct dispatch, so check
it with normalize/1 first.
@spec new() :: t()
Returns a token that is not cancelled.
Copies of the token, including copies sent to other processes on the same node, share one state, so a cancellation through any copy is seen by all.
Recognizes a cancellation token at an untyped context boundary.