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

DeadlineDelay

Waits for the original absolute monotonic boundary without extending it by resampling.

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.

DelayAsync

pub async fn DelayAsync(Limit: Deadline, Token: CancellationToken) -> Task<Result<void, DelayError>>

Waits for the original absolute monotonic boundary without extending it by resampling. Limit: Owned compatible finite deadline or explicit Endless. Token: Owned retained user cancellation observation, inert by default. Return: Unique task containing success or exact domain/range/cancellation/scheduling error. An elapsed boundary completes eagerly after checking cancellation. Default Instant is invalid; finite overflow never becomes Endless. No source input is borrowed across suspension. Native transport retains the original absolute ticks.

Example

module example.deadline_delay;
from std.task import Task, DelayAsync, CancellationSource;
from std.time import Deadline, Instant, Milliseconds;
async fn Main() -> Task<i32> {
    let Now = switch Instant.TryNow() { case .Ok { Value = Value } => break Value; case .Err => return 1; };
    let Limit = switch Deadline.TryAfter(Now, Milliseconds.Create(1)) { case .Ok { Value = Value } => break Value; case .Err => return 2; };
    switch await DelayAsync(Limit) { case .Ok => {} case .Err => return 3; }
    var Source = {
        // Keep writable result storage through the explicit noncopy payload transfer.
        var SourceCreation = CancellationSource.TryCreate();
        switch SourceCreation {
            case .Ok { Value = Value: mut CancellationSource& } => break move(Value);
            case .Err => return 4;
        }
    };
    if !Source.RequestCancellation() { return 5; }
    let Forever: Deadline = .Endless;
    switch await DelayAsync(Forever, Source.Token) { case .Ok => return 6; case .Err => return 0; }
}

DelayAsync

pub fn DelayAsync(mut Limit: Deadline) -> Task<Result<void, DelayError>>

Supplies the omitted arguments to DelayAsync. Note: Defaults: Token = CancellationToken(). Limit: Same input, ownership and lifetime contract as the full operation. Return: Exact full-operation result; no additional async frame is created.

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