MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / acquire

Method acquire

src/utils.ts:717–733  ·  view source on GitHub ↗

* Acquire the lock * * @returns A release function to call when done

()

Source from the content-addressed store, hash-verified

715 * @returns A release function to call when done
716 */
717 async acquire(): Promise<() => void> {
718 while (this.locked) {
719 await new Promise<void>((resolve) => {
720 this.waitQueue.push(resolve);
721 });
722 }
723
724 this.locked = true;
725
726 return () => {
727 this.locked = false;
728 const next = this.waitQueue.shift();
729 if (next) {
730 next();
731 }
732 };
733 }
734
735 /**
736 * Execute a function while holding the lock

Callers 9

withLockMethod · 0.95
indexAllMethod · 0.45
indexFilesMethod · 0.45
syncMethod · 0.45
runDeferredSynthesisMethod · 0.45
security.test.tsFile · 0.45

Calls 2

pushMethod · 0.80
nextFunction · 0.50

Tested by

no test coverage detected