Constructors

Methods

  • Acquires a read lock.

    Parameters

    • Optional timeout: number

      The optional maximum time to wait, in milliseconds.

    Returns Promise<ReadLock>

    A promise that's resolved with the acquired read lock. If a write lock is already held, the promise will not be resolved until the write lock is released. If other read locks are already held and there are no pending write locks, the promise is resolved immediately. Otherwise, the fairness determines whether or not the promise is resolved immediately or not.

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

  • Acquires a write lock.

    Parameters

    • Optional timeout: number

      The optional maximum time to wait, in milliseconds.

    Returns Promise<WriteLock>

    A promise that's resolved with the acquired write lock. If a read or write lock is already held, the promise will not be resolved until all locks are released.

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

  • Returns number

    The number of currently held read locks.

  • Returns boolean

    true if at least one read lock is held, or false otherwise.

  • Returns boolean

    true if a write lock is held, or false otherwise.

  • Returns string

  • Returns number

    The number of promises returned by acquireReadLock that have not yet been resolved.