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.22 kB
import { AcquireParams, DistributedRWLockConstructorProps, DistributedRWLockFactory, ExclusiveCallback, IDistributedRWLock, IReleaser, ReadLockToken, WriteLockToken } from "./types"; export declare class DistributedReadWriteLock implements IDistributedRWLock { static factory: DistributedRWLockFactory; private readonly _implementation; constructor(props: DistributedRWLockConstructorProps); maxReaders(): Promise<number>; activeReaders(): Promise<number>; get isDestroyed(): boolean; 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(): Promise<void>; get name(): string; get 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>; } //# sourceMappingURL=distributed-read-write-lock.d.ts.map