Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Semaphore

Package version

internal

A simple Semaphore

Hierarchy

  • Semaphore

Index

Constructors

constructor

Properties

limit

limit: number

The number of concurrent calls that can be made.

Methods

acquire

  • acquire(): Promise<void>

awaitedTaskCount

  • awaitedTaskCount(): number

currentLockCount

  • currentLockCount(): number

release

  • release(): void

use

  • use<T>(fn: () => T | PromiseLike<T>): Promise<T>
  • Aquires a lock from the semaphore and then execute the fn. If the fn returns a Promise, wait for that promise to settle and then release the lock back to the semaphore.

    Type parameters

    • T

    Parameters

    • fn: () => T | PromiseLike<T>

      The function that needs to be executed in the ciritical region.

        • (): T | PromiseLike<T>
        • Returns T | PromiseLike<T>

    Returns Promise<T>

    A Promise that will settle with the return value of fn.

Generated using TypeDoc