From: Jérôme Benoit Date: Thu, 13 Jul 2023 18:19:09 +0000 (+0200) Subject: refactor: cleanup pool startup code X-Git-Tag: v2.6.17~21 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e761c03377ecea9f6f729a807878a075899c8d7c;p=poolifier.git refactor: cleanup pool startup code Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 7d3be8d6..87427ad7 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -133,15 +133,7 @@ export abstract class AbstractPool< this.setupHook() this.starting = true - while ( - this.workerNodes.reduce( - (accumulator, workerNode) => - !workerNode.info.dynamic ? accumulator + 1 : accumulator, - 0 - ) < this.numberOfWorkers - ) { - this.createAndSetupWorker() - } + this.startPool() this.starting = false this.startTimestamp = performance.now() @@ -285,6 +277,18 @@ export abstract class AbstractPool< } } + private startPool (): void { + while ( + this.workerNodes.reduce( + (accumulator, workerNode) => + !workerNode.info.dynamic ? accumulator + 1 : accumulator, + 0 + ) < this.numberOfWorkers + ) { + this.createAndSetupWorker() + } + } + /** @inheritDoc */ public get info (): PoolInfo { return {