@apiratorjs/locking
Version:
A lightweight library providing both local and distributed locking primitives (mutexes and semaphores) for managing concurrency in Node.js.
23 lines • 1.09 kB
TypeScript
import { AcquireParams, AcquireToken, DistributedSemaphoreConstructorProps, IDistributedSemaphore, IReleaser } 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);
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?: AcquireToken): Promise<IReleaser>;
cancelAll(errMessage?: string): Promise<void>;
isLocked(): Promise<boolean>;
private getSemaphoreOrException;
}
//# sourceMappingURL=in-memory-distributed-semaphore.d.ts.map