From 21e6b0ef4c8b89dbf4f8c588ae50887ce1f5177f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 30 Aug 2024 11:21:06 +0200 Subject: [PATCH] refactor: move dynamic pool only getters to its own class 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 ---------------------- src/pools/cluster/dynamic.ts | 22 ++++++++++++++++++++++ src/pools/thread/dynamic.ts | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 0503e891..daef9434 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -2011,28 +2011,6 @@ export abstract class AbstractPool< */ protected abstract get busy (): boolean - /** - * Whether the pool is empty or not. - * @returns The pool emptiness boolean status. - */ - protected get empty (): boolean { - return ( - this.minimumNumberOfWorkers === 0 && - this.workerNodes.length === this.minimumNumberOfWorkers - ) - } - - /** - * Whether the pool is full or not. - * @returns The pool fullness boolean status. - */ - protected get full (): boolean { - return ( - this.workerNodes.length >= - (this.maximumNumberOfWorkers ?? this.minimumNumberOfWorkers) - ) - } - /** @inheritDoc */ public get info (): PoolInfo { return { diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index 9561fc80..4ebd6331 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -78,6 +78,28 @@ export class DynamicClusterPool< return this.full && this.internalBusy() } + /** + * Whether the pool is empty or not. + * @returns The pool emptiness boolean status. + */ + private get empty (): boolean { + return ( + this.minimumNumberOfWorkers === 0 && + this.workerNodes.length === this.minimumNumberOfWorkers + ) + } + + /** + * Whether the pool is full or not. + * @returns The pool fullness boolean status. + */ + private get full (): boolean { + return ( + this.workerNodes.length >= + (this.maximumNumberOfWorkers ?? this.minimumNumberOfWorkers) + ) + } + /** @inheritDoc */ protected get type (): PoolType { return PoolTypes.dynamic diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index 9cb068a2..34806edb 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -78,6 +78,28 @@ export class DynamicThreadPool< return this.full && this.internalBusy() } + /** + * Whether the pool is empty or not. + * @returns The pool emptiness boolean status. + */ + private get empty (): boolean { + return ( + this.minimumNumberOfWorkers === 0 && + this.workerNodes.length === this.minimumNumberOfWorkers + ) + } + + /** + * Whether the pool is full or not. + * @returns The pool fullness boolean status. + */ + private get full (): boolean { + return ( + this.workerNodes.length >= + (this.maximumNumberOfWorkers ?? this.minimumNumberOfWorkers) + ) + } + /** @inheritDoc */ protected get type (): PoolType { return PoolTypes.dynamic -- 2.34.1