Options
All
  • Public
  • Public/Protected
  • All
Menu

A ReadWriteLocker where the locks expire after a given time.

Hierarchy

Implemented by

Index

Properties

withReadLock

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

As ReadWriteLocker.withReadLock but the locked function gets called with a maintainLock callback function to reset the lock expiration every time it is called. The resulting promise will reject once the lock expires.

param

Identifier of the resource that needs to be locked.

param

A function to execute while the resource is locked. Receives a callback as input parameter to maintain the lock.

Type declaration

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

withWriteLock

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

As ReadWriteLocker.withWriteLock but the locked function gets called with a maintainLock callback function to reset the lock expiration every time it is called. The resulting promise will reject once the lock expires.

param

Identifier of the resource that needs to be locked.

param

A function to execute while the resource is locked. Receives a callback as input parameter to maintain the lock.

Type declaration

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