Terminate all workers and reject any outstanding parses.
()
| 459 | |
| 460 | /** Terminate all workers and reject any outstanding parses. */ |
| 461 | async destroy(): Promise<void> { |
| 462 | if (this.destroyed) return; |
| 463 | this.destroyed = true; |
| 464 | const ws = [...this.workers]; |
| 465 | this.workers.clear(); |
| 466 | this.pending.clear(); |
| 467 | this.parseCounts.clear(); |
| 468 | this.idle = []; |
| 469 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 470 | this.settle(job, undefined, new Error('parse pool destroyed')); |
| 471 | } |
| 472 | this.inflight.clear(); |
| 473 | this.queue = []; |
| 474 | await Promise.all(ws.map((w) => Promise.resolve(w.terminate()).catch(() => { /* already gone */ }))); |
| 475 | } |
| 476 | } |