Skip to content

Commit

Permalink
refactor: move dynamic pool only getters to its own class
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
  • Loading branch information
jerome-benoit committed Aug 30, 2024
1 parent 28b119c commit 74970f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/pools/abstract-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,18 +493,6 @@ export abstract class AbstractPool<
)
}

/**
* 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
)
}

/**
* The approximate pool utilization.
*
Expand Down Expand Up @@ -724,18 +712,6 @@ export abstract class AbstractPool<
}
}

/**
* 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)
)
}

/**
* Whether the pool is back pressured or not.
*
Expand Down
24 changes: 24 additions & 0 deletions src/pools/thread/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ export class DynamicThreadPool<
}
}

/**
* 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
Expand Down

0 comments on commit 74970f2

Please sign in to comment.