X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fthread%2Fdynamic.ts;h=6def273e24bcc413a880ad8fa793fad74a9e36d5;hb=9b358e72dbd061a7b94708d7d3c64e9dbbefaab4;hp=b03ca47e27ab272233338e8e4fb751bb8de0d0e4;hpb=e102732c0e3966b81834b2c0bdd087eb051162ad;p=poolifier.git diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index b03ca47e..6def273e 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -1,5 +1,7 @@ -import { type PoolType, PoolTypes } from '../pool' -import { FixedThreadPool, type ThreadPoolOptions } from './fixed' +import { type Worker } from 'node:worker_threads' +import { type PoolOptions, type PoolType, PoolTypes } from '../pool' +import { checkDynamicPoolSize } from '../utils' +import { FixedThreadPool } from './fixed' /** * A thread pool with a dynamic number of threads, but a guaranteed minimum number of threads. @@ -28,9 +30,10 @@ export class DynamicThreadPool< min: number, protected readonly max: number, filePath: string, - opts: ThreadPoolOptions = {} + opts: PoolOptions = {} ) { super(min, filePath, opts) + checkDynamicPoolSize(this.numberOfWorkers, this.max) } /** @inheritDoc */ @@ -38,11 +41,6 @@ export class DynamicThreadPool< return PoolTypes.dynamic } - /** @inheritDoc */ - protected get maxSize (): number { - return this.max - } - /** @inheritDoc */ protected get busy (): boolean { return this.full && this.internalBusy()