MCPcopy
hub / github.com/colbymchenry/codegraph / spawnOne

Method spawnOne

src/extraction/parse-pool.ts:192–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190 }
191
192 private spawnOne(): void {
193 if (this.destroyed || this.workers.size >= this.maxSize || !this.healthy) return;
194 let w: ParsePoolWorker;
195 try {
196 w = this.createWorker();
197 } catch {
198 this.totalCrashes++; // counts toward the circuit breaker
199 return;
200 }
201 this.workers.add(w);
202 this.pending.add(w);
203 this.parseCounts.set(w, 0);
204 w.on('message', (m) => this.onMessage(w, (m ?? {}) as ParseWorkerMessage));
205 w.on('error', (e) => this.onWorkerGone(w, `Worker error: ${e?.message ?? 'unknown'}`));
206 w.on('exit', (code) => { if (code !== 0) this.onWorkerGone(w, `Worker exited with code ${code}`); });
207 // Load grammars; the worker replies 'grammars-loaded' and only then is idle.
208 w.postMessage({ type: 'load-grammars', languages: this.languages });
209 }
210
211 private onMessage(w: ParsePoolWorker, m: ParseWorkerMessage): void {
212 if (m.type === 'grammars-loaded') {

Callers 5

constructorMethod · 0.95
onWorkerGoneMethod · 0.95
recycleMethod · 0.95
onTimeoutMethod · 0.95
drainMethod · 0.95

Calls 5

onMessageMethod · 0.95
onWorkerGoneMethod · 0.95
setMethod · 0.80
onMethod · 0.65
postMessageMethod · 0.65

Tested by

no test coverage detected