MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / acquire

Method acquire

src/utils/TaskSemaphore.ts:39–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37 }
38
39 async acquire(): Promise<() => void> {
40 // Only count as waiting if the permit won't be granted immediately.
41 const willQueue = this.sem.isLocked()
42 const gen = this._generation
43 if (willQueue) this._waiting++
44 try {
45 const [, release] = await this.sem.acquire()
46 if (willQueue && gen === this._generation) this._waiting--
47 return release
48 } catch (e) {
49 if (willQueue && gen === this._generation) this._waiting--
50 throw e
51 }
52 }
53
54 /**
55 * Rejects all queued waiters and resets the waiting count to 0.

Callers 8

scanDirectoryMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected