MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / execWithMutexId

Function execWithMutexId

panel/src/app/utils/sync.ts:21–34  ·  view source on GitHub ↗
(id: string, fn: () => Promise<T>)

Source from the content-addressed store, hash-verified

19}
20
21export async function execWithMutexId<T>(id: string, fn: () => Promise<T>) {
22 let mutex = mutexIdMap.get(id);
23 if (!mutex) {
24 mutex = new Mutex();
25 mutexIdMap.set(id, mutex);
26 }
27 const releaseLock = await mutex.acquire();
28 try {
29 return await fn();
30 } finally {
31 releaseLock();
32 mutexIdMap.delete(id);
33 }
34}

Callers 2

Calls 4

fnFunction · 0.85
deleteMethod · 0.65
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected