Options
All
  • Public
  • Public/Protected
  • All
Menu

A resource locker making use of the async-lock library. Read and write locks use the same locks so no preference is given to any operations. This should be changed at some point though, see #542.

Hierarchy

  • SingleThreadedResourceLocker

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Private Readonly locks

locks: AsyncLock

Protected Readonly logger

logger: Logger = ...

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>

withWriteLock

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