MCPcopy
hub / github.com/garrytan/gstack / withBoardMutex

Function withBoardMutex

design/src/daemon.ts:122–136  ·  view source on GitHub ↗
(id: string, fn: () => Promise<T>)

Source from the content-addressed store, hash-verified

120}
121
122async function withBoardMutex<T>(id: string, fn: () => Promise<T>): Promise<T> {
123 const prev = boardMutex.get(id) || Promise.resolve();
124 let release!: () => void;
125 const next = new Promise<void>((r) => {
126 release = r;
127 });
128 boardMutex.set(id, prev.then(() => next));
129 await prev;
130 try {
131 return await fn();
132 } finally {
133 release();
134 if (boardMutex.get(id) === next) boardMutex.delete(id);
135 }
136}
137
138function markMeaningfulActivity(): void {
139 lastMeaningfulActivity = Date.now();

Callers 1

fetchHandlerFunction · 0.85

Calls 3

fnFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected