Class PartialReadWriteLocker

A BaseReadWriteLocker that stores the counter and its associated locks in memory. The consequence of this is that multiple read requests are possible as long as they occur on the same worker thread. A read request from a different worker thread will have to wait until those from the current worker thread are finished.

The main reason for this class is due to the file locker that we use only allowing locks to be released by the same worker thread that acquired them.

Hierarchy

Constructors

Properties

countLocker: ResourceLocker
readCount: Map<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.