Semaphore instance.

Permits pre-configured maximum simultaneous acquires.

It is expected that each acquire is followed by corresponding release.

Hierarchy

  • Semaphore

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Acquires lock.

    Decreases the number of available permits when available, or blocks until one available.

    Parameters

    • Optional acquirer: AbortSignal

    Returns Promise<void>

    A promise resolved either immediately if permit available, or once permit becomes available after release call. This promise may be rejected with LockFailedError when semaphore closed, or when the lock acquire aborted.

    Params

    acquirer - Semaphore acquire abort signal. The returned promise would be rejected once the acquire aborted.

  • Releases previously acquired lock.

    Increases the number of available permits. If there are pending acquires awaiting for the lock, the very first one receives it, while the rest continue to wait.

    Returns void

Generated using TypeDoc