Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ISemaphore

Hierarchy

Implemented by

Index

Methods

acquire

  • acquire(permits?: number): Promise<void>
  • Acquires the given number of permits if they are available, and returns immediately, reducing the number of available permits by the given amount. If insufficient permits are available returned promise is not resolved until until there are sufficient number of available permits or this {ISemaphore} is destroyed.

    Parameters

    • Optional permits: number

    Returns Promise<void>

availablePermits

  • availablePermits(): Promise<number>
  • Returns the current number of permits currently available in this semaphore. This message is idempotent.

    Returns Promise<number>

destroy

  • destroy(): Promise<void>

drainPermits

  • drainPermits(): Promise<number>
  • Acquires and returns all permits that are immediately available.

    Returns Promise<number>

getName

  • getName(): string

getPartitionKey

  • getPartitionKey(): string

getServiceName

  • getServiceName(): string

init

  • init(permits: number): Promise<boolean>
  • Try to initialize this ISemaphore instance with the given permit count.

    Parameters

    • permits: number

    Returns Promise<boolean>

reducePermits

  • reducePermits(reduction: number): Promise<void>
  • Shrinks the number of available permits by the indicated reduction.

    Parameters

    • reduction: number

    Returns Promise<void>

release

  • release(permits?: number): Promise<void>
  • Releases the given number of permits, increasing the number of available permits by that amount. There is no requirement that a thread that releases a permit must have acquired that permit by calling one of the acquire()acquire methods. Correct usage of a semaphore is established by programming convention in the application

    Parameters

    • Optional permits: number

    Returns Promise<void>

tryAcquire

  • tryAcquire(permits: number, timeout: Long | number): Promise<boolean>
  • Acquires the given number of permits, if they are available, and returns immediately, with the value true, reducing the number of available permits by the given amount. If insufficient permits are available then this method will return immediately with the value false and the number of available permits is unchanged.

    Parameters

    • permits: number
    • timeout: Long | number

    Returns Promise<boolean>

Generated using TypeDoc