From e761c03377ecea9f6f729a807878a075899c8d7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 13 Jul 2023 20:19:09 +0200 Subject: [PATCH] refactor: cleanup pool startup code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 { -- 2.34.1