menu
Task
import { Task } from "destack:async";
Single-consumer asynchronous result on its own fiber.
Awaiting a task blocks the current fiber and moves the result out. Cancellation requests are delivered cooperatively at cancellable operations.
1export class Task<T> {2 static resolve<T>(value: T): Task<T>;3 static spawn<T>(body: () => T): Task<T>;4 static block<T>(task: Task<T>): T;5 cancel(): void;6}Members
static resolve<T>(value: T): Task<T>Create an already completed task.
static spawn<T>(body: () => T): Task<T>Run one body on a fresh fiber and expose its result.
static block<T>(task: Task<T>): TBlock the current fiber until a task completes, moving the result out.
cancel(): voidRequest cancellation at the next suspension.