Terminate all workers and reject any outstanding parses.
()
| 440 | |
| 441 | /** Terminate all workers and reject any outstanding parses. */ |
| 442 | async destroy(): Promise<void> { |
| 443 | if (this.destroyed) return; |
| 444 | this.destroyed = true; |
| 445 | const ws = [...this.workers]; |
| 446 | this.workers.clear(); |
| 447 | this.pending.clear(); |
| 448 | this.parseCounts.clear(); |
| 449 | this.idle = []; |
| 450 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 451 | this.settle(job, undefined, new Error('parse pool destroyed')); |
| 452 | } |
| 453 | this.inflight.clear(); |
| 454 | this.queue = []; |
| 455 | await Promise.all(ws.map((w) => Promise.resolve(w.terminate()).catch(() => { /* already gone */ }))); |
| 456 | } |
| 457 | } |