Options
All
  • Public
  • Public/Protected
  • All
Menu

A ReadWriteLocker that gives no priority to read or write operations: both use the same lock.

Hierarchy

  • EqualReadWriteLocker

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Private Readonly locker

Methods

Private withLock

  • withLock<T>(identifier: ResourceIdentifier, whileLocked: () => T | Promise<T>): Promise<T>
  • Acquires a new lock for the requested identifier. Will resolve when the input function resolves.

    Type parameters

    • T

    Parameters

    • identifier: ResourceIdentifier

      Identifier of resource that needs to be locked.

    • whileLocked: () => T | Promise<T>

      Function to resolve while the resource is locked.

        • (): T | Promise<T>
        • Returns T | Promise<T>

    Returns Promise<T>

withReadLock

  • withReadLock<T>(identifier: ResourceIdentifier, whileLocked: () => T | Promise<T>): Promise<T>
  • Run the given function while the resource is locked. The lock will be released when the (async) input function resolves. This function should be used for operations that only require reading the resource.

    Type parameters

    • T

    Parameters

    • identifier: ResourceIdentifier
    • whileLocked: () => T | Promise<T>
        • (): T | Promise<T>
        • Returns T | Promise<T>

    Returns Promise<T>

withWriteLock

  • withWriteLock<T>(identifier: ResourceIdentifier, whileLocked: () => T | Promise<T>): Promise<T>
  • Run the given function while the resource is locked. The lock will be released when the (async) input function resolves. This function should be used for operations that could modify the resource.

    Type parameters

    • T

    Parameters

    • identifier: ResourceIdentifier
    • whileLocked: () => T | Promise<T>
        • (): T | Promise<T>
        • Returns T | Promise<T>

    Returns Promise<T>