interface ReadLock {
    isHeld(): boolean;
    release(): void;
    upgradeToWriteLock(timeout?): Promise<WriteLock>;
}

Methods

  • Returns boolean

    true if this read lock is still held, or false otherwise.

  • Releases the read lock.

    Returns void

    Throws

    If the read lock is no longer held.

  • Upgrades the read lock to a write lock. Afterwards the read lock will no longer be held.

    Parameters

    • Optional timeout: number

      The optional maximum time to wait, in milliseconds.

    Returns Promise<WriteLock>

    A promise that's resolved when the write lock has been acquired. If multiple read locks are already held, the promise will not be resolved until all read locks are released.

    If a timeout is given and it expires, the promise will be rejected.

    Throws

    If the read lock is no longer held.