Narra

Reference

std/thread

std/thread

Threads that run in a scope.

narra
import * as Thread from "std/thread"

The guide teaches it in chapter 15, Threads and shared state.

This page is generated by scripts/std/generate.nra from narrac query --json interface std/thread. Do not edit it.

Types

Scope

narra
export opaque struct Scope

Functions: scope, start, startAsync.

Thread

narra
export opaque struct Thread<T>

Functions: start, startAsync, join.

Functions

scope

narra
export function scope<T, effect E>(body: (Scope) => T uses E): T uses E, alloc

Effects: E, alloc.

start

narra
export function start<T, effect E>(threadScope: Scope, escaping work: () => T uses E): Thread<T> uses E, alloc

Effects: E, alloc.

startAsync

narra
export function startAsync<T, effect E>(threadScope: Scope, escaping work: () => Async<T> uses E): Thread<T> uses E, alloc

Effects: E, alloc.

join

narra
export function join<T>(thread: Thread<T>): T from thread

Effects: none.