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.

22 lines 1.02 kB
import { AcquireParams, DistributedSemaphoreConstructorProps, DistributedSemaphoreFactory, IDistributedSemaphore, IReleaser, SemaphoreToken } from "./types"; export declare class DistributedSemaphore implements IDistributedSemaphore { static factory: DistributedSemaphoreFactory; private readonly _implementation; constructor(props: DistributedSemaphoreConstructorProps); 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(): Promise<void>; get name(): string; get maxCount(): number; get implementation(): string; freeCount(): Promise<number>; acquire(params?: { timeoutMs?: number; }): Promise<IReleaser<SemaphoreToken>>; cancelAll(errMessage?: string): Promise<void>; isLocked(): Promise<boolean>; } //# sourceMappingURL=distributed-semaphore.d.ts.map