Terminate all workers and reject any outstanding parses.
()
| 543 | |
| 544 | /** Terminate all workers and reject any outstanding parses. */ |
| 545 | async destroy(): Promise<void> { |
| 546 | if (this.destroyed) return; |
| 547 | this.destroyed = true; |
| 548 | const ws = [...this.workers]; |
| 549 | this.workers.clear(); |
| 550 | this.pending.clear(); |
| 551 | this.parseCounts.clear(); |
| 552 | this.idle = []; |
| 553 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 554 | this.settle(job, undefined, new Error('parse pool destroyed')); |
| 555 | } |
| 556 | this.inflight.clear(); |
| 557 | this.queue = []; |
| 558 | await Promise.all(ws.map((w) => this.terminateSettled(w))); |
| 559 | } |
| 560 | } |