UNPKG

@apiratorjs/locking

Version:

A lightweight library providing both local and distributed locking primitives (mutexes, semaphores, and read-write locks) for managing concurrency in Node.js.

25 lines 1.2 kB
import { AcquireParams, DistributedSemaphoreConstructorProps, IDistributedSemaphore, IReleaser, SemaphoreToken } from "../types"; import { Semaphore } from "../semaphore"; export declare class InMemoryDistributedSemaphore implements IDistributedSemaphore { private readonly _registry; private readonly _type; readonly maxCount: number; readonly name: string; private _isDestroyed; constructor(props: DistributedSemaphoreConstructorProps, _registry: Map<string, Semaphore>, _type?: string); waitForFullyUnlock(): Promise<void>; waitForAnyUnlock(): Promise<void>; get isDestroyed(): boolean; runExclusive<T>(fn: () => Promise<T> | T): Promise<T>; runExclusive<T>(params: AcquireParams, fn: () => Promise<T> | T): Promise<T>; destroy(message?: string): Promise<void>; readonly implementation: string; freeCount(): Promise<number>; acquire(params?: { timeoutMs?: number; }, acquireToken?: SemaphoreToken): Promise<IReleaser<SemaphoreToken>>; cancelAll(errMessage?: string): Promise<void>; isLocked(): Promise<boolean>; private getSemaphoreOrException; } //# sourceMappingURL=in-memory-distributed-semaphore.d.ts.map