Working setup
This commit is contained in:
parent
e3a90833ff
commit
2dfb8b71e5
16 changed files with 459 additions and 318 deletions
|
|
@ -18,7 +18,7 @@ export class Locks<T> {
|
|||
[() => unknown, (err: unknown) => unknown][]
|
||||
>();
|
||||
|
||||
public constructor(private readonly logger?: Logger) {}
|
||||
public constructor(private readonly logger?: Logger) { }
|
||||
|
||||
/**
|
||||
* Executes a function while holding exclusive locks on one or more keys.
|
||||
|
|
@ -125,6 +125,18 @@ export class Locks<T> {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits until a lock is released without acquiring it.
|
||||
* Operations are queued in FIFO order.
|
||||
*
|
||||
* @param key The key to wait for
|
||||
* @returns Promise that resolves when lock is released
|
||||
*/
|
||||
public async waitForLockWithoutAcquiringLock(key: T): Promise<void> {
|
||||
await this.waitForLock(key);
|
||||
this.unlock(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases a lock and grants access to the next waiting operation in FIFO order.
|
||||
* Removes the key from locked set if no waiters.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue