@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.38 kB
TypeScript
import { AcquireParams, DistributedRWLockConstructorProps, ExclusiveCallback, IDistributedRWLock, IReleaser, ReadLockToken, WriteLockToken } from "../types";
import { ReadWriteLock } from "../read-write-lock";
export declare class InMemoryDistributedReadWriteLock implements IDistributedRWLock {
private readonly _registry;
private readonly _type;
readonly name: string;
private _isDestroyed;
constructor(props: DistributedRWLockConstructorProps, _registry?: Map<string, ReadWriteLock>, _type?: string);
get isDestroyed(): boolean;
maxReaders(): Promise<number>;
activeReaders(): Promise<number>;
withReadLock<T>(fn: ExclusiveCallback<T>): Promise<T>;
withReadLock<T>(params: AcquireParams, fn: ExclusiveCallback<T>): Promise<T>;
withWriteLock<T>(fn: ExclusiveCallback<T>): Promise<T>;
withWriteLock<T>(params: AcquireParams, fn: ExclusiveCallback<T>): Promise<T>;
destroy(message?: string): Promise<void>;
readonly implementation: string;
acquireRead(params?: AcquireParams): Promise<IReleaser<ReadLockToken>>;
acquireWrite(params?: AcquireParams): Promise<IReleaser<WriteLockToken>>;
cancelAll(errMessage?: string): Promise<void>;
isReadLocked(): Promise<boolean>;
isWriteLocked(): Promise<boolean>;
private getRWLockOrException;
}
//# sourceMappingURL=in-memory-distributed-read-write-lock.d.ts.map