Used for creating read and write locks.
Used for storing the amount of active read operations on a resource.
Used to generate the identifier for the lock that is applied when updating the counter.
Used to generate the identifier that will be used in the storage for storing the counter.
Protected
Readonly
countProtected
Readonly
countProtected
Readonly
lockerProtected
Readonly
readProtected
Readonly
storageProtected
getThis key is used for storing the count of active read operations.
Protected
getGenerate the identifier that will be used to acquire the count lock for the given identifier.
There will be cases where this lock needs to be acquired
while an active lock on the main resource is still being maintained.
This means that if the input resourceLocker
and countLocker
use the same locking system
this generated identifier needs to be different.
Protected
modifyUpdates the count with the given modifier. Creates the data if it didn't exist yet. Deletes the data when the count reaches zero.
Protected
withAcquires a new lock for the requested identifier. Will resolve when the input function resolves.
Identifier of resource that needs to be locked.
Function to resolve while the resource is locked.
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.
Identifier of the resource that needs to be locked.
A function to execute while the resource is locked.
A promise resolving when the lock is released.
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.
Identifier of the resource that needs to be locked.
A function to execute while the resource is locked.
A promise resolving when the lock is released.
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.