From: Jérôme Benoit Date: Fri, 30 Aug 2024 09:21:06 +0000 (+0200) Subject: refactor: move dynamic pool only getters to its own class X-Git-Tag: v4.2.8~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=21e6b0ef4c8b89dbf4f8c588ae50887ce1f5177f;p=poolifier.git refactor: move dynamic pool only getters to its own class Signed-off-by: Jérôme Benoit --- 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