From: Jérôme Benoit Date: Mon, 10 Apr 2023 04:15:38 +0000 (+0200) Subject: refactor: cleanup pool busyness checks X-Git-Tag: v2.4.6~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0527b6db895355140ed6fa2f740caab3a41b2f9f;p=poolifier.git refactor: cleanup pool busyness checks Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 1a1a89fb..fea4847d 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -336,11 +336,7 @@ export abstract class AbstractPool< */ protected chooseWorkerNode (): [number, WorkerNode] { let workerNodeKey: number - if ( - this.type === PoolType.DYNAMIC && - !this.full && - this.findFreeWorkerNodeKey() === -1 - ) { + if (this.type === PoolType.DYNAMIC && !this.full && this.internalBusy()) { const workerCreated = this.createAndSetupWorker() this.registerWorkerMessageListener(workerCreated, message => { if ( diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index 9f9abb01..89180f1f 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -46,6 +46,6 @@ export class DynamicClusterPool< /** @inheritDoc */ public get busy (): boolean { - return this.full && this.findFreeWorkerNodeKey() === -1 + return this.full && this.internalBusy() } } diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index e1565d00..05b61684 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -47,6 +47,6 @@ export class DynamicThreadPool< /** @inheritDoc */ public get busy (): boolean { - return this.full && this.findFreeWorkerNodeKey() === -1 + return this.full && this.internalBusy() } }