Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Development · Evolving reference

CancellationToken

Retains copyable cooperative cancellation observation independently of authority. Defaults are inert. Copies and observations allocate nothing. Distinct retained tokens may be observed concurrently; move/assignment of one handle needs external serialization. Destruction never requests cancellation or waits for completion.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

Module std.task

import std.task;

Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.

CancellationToken

pub final class CancellationToken

Retains copyable cooperative cancellation observation independently of authority. Defaults are inert. Copies and observations allocate nothing. Distinct retained tokens may be observed concurrently; move/assignment of one handle needs external serialization. Destruction never requests cancellation or waits for completion.

CancellationToken.init

pub init()

Creates inert observation without allocation.

CancellationToken.init

pub init(Source: readonly Self&)

Retains existing backing without allocation. Source: Retained token.

CancellationToken.init

pub init(Source: mut Self&&)

Transfers backing and clears Source. Source: Explicit moved token.

CancellationToken.operator

pub fn operator =(Source: readonly Self&) -> void

Retains before releasing old backing, including exact self-assignment. Source: Retained token. Return: No value after retaining Source and releasing the previous token lease.

CancellationToken.operator

pub fn operator =(Source: mut Self&&) -> void

Transfers backing without allocation, preserving exact self-move. Source: Explicit moved token. Return: No value after transferring the token lease; exact self-move is unchanged.

CancellationToken.CanBeCancelled

pub CanBeCancelled: bool;

Reports whether observation has backing authority. Return: False for default/moved token.

CancellationToken.IsCancellationRequested

pub IsCancellationRequested: bool;

Acquires cooperative request state without scheduling. Return: True after cancellation request, false for inert token.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library