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

Method acquire

src/utils.ts:719–735  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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