Skip to content

std/concurrent

Import with import std/concurrent.

Types

type Task<'T>

In-flight or completed asynchronous computation. Task<'T> carries one type parameter — the body’s return type. Errors-as-values via Result<'T, 'E> are the universal Nomi idiom, so try await(task) composes the same way try fetch_user(42) does.

Task<'T> values are scoped to the enclosing concurrent { } block: they cannot escape the block (the analyzer rejects return t, Channel.send(ch, t), etc.) and they must be consumed by await (or explicitly discarded via _ = await(t)). The analyzer enforces all of this: async outside concurrent, un-awaited Task<'T> values, and Task<'T> escapes are rejected.

fn async<'T>(body: () -> 'T): Task<'T>

type function on Task

Spawn body as a parallel task in the enclosing concurrent { } block. Legal only inside the dynamic extent of concurrent { }; the analyzer rejects async calls reachable from a function body without a concurrent ancestor.

fn await<'T>(task: Task<'T>): 'T

type function on Task

Block until task completes and return its value. Result-typed task bodies bubble errors through try await(t) like any other Result-returning call.

impl Debug

fn inspect<'T>(value: Task<'T>): String where 'T: Debug

impl Debug.inspect