MCPcopy
hub / github.com/toeverything/AFFiNE / SingletonLocker

Class SingletonLocker

packages/common/nbstore/src/storage/lock.ts:5–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3}
4
5export class SingletonLocker implements Locker {
6 lockedResource = new Map<string, Lock>();
7 constructor() {}
8
9 async lock(domain: string, resource: string) {
10 const key = `${domain}:${resource}`;
11 let lock = this.lockedResource.get(key);
12
13 if (!lock) {
14 lock = new Lock();
15 this.lockedResource.set(key, lock);
16 }
17
18 await lock.acquire();
19
20 return lock;
21 }
22}
23
24export class Lock {
25 private inner: Promise<void> = Promise.resolve();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected