Terminate all workers and reject any outstanding parses.
()
| 343 | |
| 344 | /** Terminate all workers and reject any outstanding parses. */ |
| 345 | async destroy(): Promise<void> { |
| 346 | if (this.destroyed) return; |
| 347 | this.destroyed = true; |
| 348 | const ws = [...this.workers]; |
| 349 | this.workers.clear(); |
| 350 | this.pending.clear(); |
| 351 | this.parseCounts.clear(); |
| 352 | this.idle = []; |
| 353 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 354 | this.settle(job, undefined, new Error('parse pool destroyed')); |
| 355 | } |
| 356 | this.inflight.clear(); |
| 357 | this.queue = []; |
| 358 | await Promise.all(ws.map((w) => Promise.resolve(w.terminate()).catch(() => { /* already gone */ }))); |
| 359 | } |
| 360 | } |