Terminate all workers and reject any outstanding parses.
()
| 568 | |
| 569 | /** Terminate all workers and reject any outstanding parses. */ |
| 570 | async destroy(): Promise<void> { |
| 571 | if (this.destroyed) return; |
| 572 | this.destroyed = true; |
| 573 | const ws = [...this.workers]; |
| 574 | this.workers.clear(); |
| 575 | this.pending.clear(); |
| 576 | this.parseCounts.clear(); |
| 577 | this.idle = []; |
| 578 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 579 | this.settle(job, undefined, new Error('parse pool destroyed')); |
| 580 | } |
| 581 | this.inflight.clear(); |
| 582 | this.queue = []; |
| 583 | await Promise.all(ws.map((w) => this.terminateSettled(w))); |
| 584 | } |
| 585 | } |