MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / withLock

Function withLock

test/unit/mcpServer_test.js:265–276  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

263 let lock = Promise.resolve()
264
265 async function withLock(fn) {
266 const prev = lock
267 let release
268 lock = new Promise(r => (release = r))
269
270 await prev
271 try {
272 return await fn()
273 } finally {
274 release()
275 }
276 }
277
278 const task1 = withLock(async () => {
279 executionOrder.push('start1')

Callers 1

mcpServer_test.jsFile · 0.70

Calls 2

fnFunction · 0.70
releaseFunction · 0.50

Tested by

no test coverage detected