* 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)
| 366 | * is left alone, and judged at the next shrink. |
| 367 | */ |
| 368 | private replaceIfHeavy(w: PoolWorker, heldBytes: number): void { |
| 369 | if (heldBytes <= this.idleKeepBytes || !this.quiescent || this.workers.size !== 1) return; |
| 370 | this.workers.clear(); |
| 371 | this.idle = []; |
| 372 | this.everReady = false; |
| 373 | this.retire(w); |
| 374 | this.spawnOne(); |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Ask an idle worker to exit by itself: it closes its connections and |