Skip to main content

interface WaitGroup

A WaitGroup is a way to perform fork-join logic in an asynchronous context. It allows a process to create an arbitrary amount of sub-processes, and wait for all of them to finish before continuing.

Companion namespace: WaitGroup

Methods

add

Adds the given amount of processes to the WaitGroup.

Definition

add(amount?: number): void;

Parameters

NameTypeDescription
amountnumber(default: 1) the amount of processes to add

done

Informs the WaitGroup that a process has completed.

Definition

done(amount?: number): void;

Parameters

NameTypeDescription
amountnumber(default: 1) the amount of processes to add

wait

Blocks until all the processes in the WaitGroup have completed.

Definition

wait(): Promise<void>;