UNPKG

multithreading

Version:

The missing standard library for multithreading in JavaScript (Works in the browser, Node.js, Deno, Bun).

19 lines (18 loc) 694 B
import { Serializable, toDeserialized, toSerialized } from "../shared.js"; export interface BarrierWaitResult { isLeader: boolean; } export declare class Barrier extends Serializable { #private; constructor(n?: number, _buffer?: SharedArrayBuffer); /** * Blocks the current thread until all participating threads have reached the barrier. */ blockingWait(): BarrierWaitResult; /** * Asynchronously waits until all participating threads have reached the barrier. */ wait(): Promise<BarrierWaitResult>; [toSerialized](): readonly [SharedArrayBuffer]; static [toDeserialized](buffer: ReturnType<Barrier[typeof toSerialized]>[0]): Barrier; }