* The last check on a kept worker: one that still holds a lot after its trim * is ended like the rest, with one clean worker in its place, so that keeping * a worker can't keep hold of what a large query left behind. Calls that come * while the clean one starts are served in process. Back a
(w: PoolWorker, heldBytes: number)
| 396 | * is left alone, and judged at the next shrink. |
| 397 | */ |
| 398 | private replaceIfHeavy(w: PoolWorker, heldBytes: number): void { |
| 399 | if (heldBytes <= this.idleKeepBytes || !this.quiescent || this.workers.size !== 1) return; |
| 400 | this.workers.clear(); |
| 401 | this.idle = []; |
| 402 | this.everReady = false; |
| 403 | this.retire(w); |
| 404 | this.spawnOne(); |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Ask an idle worker to exit by itself: it closes its connections and |