From: Jérôme Benoit Date: Sun, 4 Jun 2023 13:53:23 +0000 (+0200) Subject: refactor: factor out pool fullness detection X-Git-Tag: v2.5.3~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=dea903a811a58acdf93f11379b347bfd8088e970;p=poolifier.git refactor: factor out pool fullness detection Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 5d7e8cd8..43abfda7 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -357,7 +357,9 @@ export abstract class AbstractPool< * * The pool filling boolean status. */ - protected abstract get full (): boolean + protected get full (): boolean { + return this.workerNodes.length >= this.maxSize + } /** * Whether the pool is busy or not. diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index eb86ba85..b75b3f80 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -43,11 +43,6 @@ export class DynamicClusterPool< return this.max } - /** @inheritDoc */ - protected get full (): boolean { - return this.workerNodes.length >= this.max - } - /** @inheritDoc */ protected get busy (): boolean { return this.full && this.internalBusy() diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index 0ca0250c..f22906df 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -54,7 +54,7 @@ export class FixedClusterPool< public constructor ( numberOfWorkers: number, filePath: string, - public readonly opts: ClusterPoolOptions = {} + protected readonly opts: ClusterPoolOptions = {} ) { super(numberOfWorkers, filePath, opts) } @@ -119,11 +119,6 @@ export class FixedClusterPool< return this.numberOfWorkers } - /** @inheritDoc */ - protected get full (): boolean { - return this.workerNodes.length >= this.numberOfWorkers - } - /** @inheritDoc */ protected get busy (): boolean { return this.internalBusy() diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index 8cdb0d5c..90889c9b 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -43,11 +43,6 @@ export class DynamicThreadPool< return this.max } - /** @inheritDoc */ - protected get full (): boolean { - return this.workerNodes.length >= this.max - } - /** @inheritDoc */ protected get busy (): boolean { return this.full && this.internalBusy() diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index be1a8baa..f0a49056 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -116,11 +116,6 @@ export class FixedThreadPool< return this.numberOfWorkers } - /** @inheritDoc */ - protected get full (): boolean { - return this.workerNodes.length >= this.numberOfWorkers - } - /** @inheritDoc */ protected get busy (): boolean { return this.internalBusy()