Skip to main content

namespace Semaphore

A Semaphore is a generalized version of a Mutex, allowing boundaries on the amount of concurrent processes that can have simultaneous access to a shared resource. The semaphore is weighted, meaning that the semaphore has a maximum size/capacity available for the shared resources. When acquiring the resource, a weight can be provided allowing more intensive tasks to acquire a larger share of the shared resource, preventing too many other tasks from also acquiring the resource.

Companion interface: Semaphore

Interfaces

NameDescription
Semaphore.ConstructorsDefines the static Semaphore API.

Static Methods

create

Returns a new Semaphore instance with the given configuration.

Definition

create(options: {
      maxSize: number;
    }): Semaphore;

Parameters

NameTypeDescription
options{
      maxSize: number;
    }
the options for the Semaphore, including:
- maxSize: the maximum size/capacity for the semaphore