Class GreedyReadWriteLocker

A BaseReadWriteLocker that uses the same locker for the main lock and the count lock, and uses a KeyValueStorage for keeping track of the counter.

Since it is completely dependent on other implementations, this locker is threadsafe if its inputs are as well.

Hierarchy

Constructors

Properties

countLocker: ResourceLocker
countSuffix: string
readSuffix: string
storage: KeyValueStorage<string, number>

Methods

  • 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

    Returns Promise<T>

    A promise resolving when the lock is released.