Options
All
  • Public
  • Public/Protected
  • All
Menu

Wraps around an existing ReadWriteLocker and adds expiration logic to prevent locks from getting stuck.

Hierarchy

  • WrappedExpiringReadWriteLocker

Implements

Index

Constructors

constructor

Properties

Protected Readonly expiration

expiration: number

Protected Readonly locker

Protected Readonly logger

logger: Logger = ...

Methods

Private expiringPromise

  • expiringPromise<T>(identifier: ResourceIdentifier, whileLocked: (maintainLock: () => void) => T | Promise<T>): Promise<T>
  • Creates a Promise that either resolves the given input function or rejects if time runs out, whichever happens first. The input function can reset the timer by calling the maintainLock function it receives. The ResourceIdentifier is only used for logging.

    Type parameters

    • T

    Parameters

    • identifier: ResourceIdentifier
    • whileLocked: (maintainLock: () => void) => T | Promise<T>
        • (maintainLock: () => void): T | Promise<T>
        • Parameters

          • maintainLock: () => void
              • (): void
              • Returns void

          Returns T | Promise<T>

    Returns Promise<T>

withReadLock

  • withReadLock<T>(identifier: ResourceIdentifier, whileLocked: (maintainLock: () => void) => T | Promise<T>): Promise<T>

withWriteLock

  • withWriteLock<T>(identifier: ResourceIdentifier, whileLocked: (maintainLock: () => void) => T | Promise<T>): Promise<T>