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

Properties

expiration: number
logger: Logger = ...

Methods

  • 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<T>(identifier: ResourceIdentifier, whileLocked: (maintainLock: () => void) => T | Promise<T>): Promise<T>
  • withWriteLock<T>(identifier: ResourceIdentifier, whileLocked: (maintainLock: () => void) => T | Promise<T>): Promise<T>