UNPKG

@jsdsl/semaphore

Version:

A Promise-based semaphore implementation.

17 lines (16 loc) 572 B
import "promise-any-polyfill"; import { SemaphoreLock } from "./semaphore-lock"; declare type OutstandingLockMap = { [id: string]: SemaphoreLock; }; export declare class Semaphore { protected readonly maxLockCount: number; protected outstandingLocks: OutstandingLockMap; constructor(maxLockCount?: number); protected getLockPromises(): Promise<string>[]; getLock(): Promise<SemaphoreLock>; performLockedOperation<T>(operation: () => (T | PromiseLike<T>)): Promise<T>; getLockCount(): number; getMaximumLockCount(): number; } export {};