X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fcluster%2Fdynamic.ts;h=e8e51947246602194951bb4366c68c9cf9d63ad4;hb=8f081cca7093fee8a6e565c4b05d10fa30565cd1;hp=ce28e421544131e2f3b5efbf762e66b1c8b71103;hpb=9d9fb7b64a28d150583fe1bcd895893f6736d9d4;p=poolifier.git diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index ce28e421..e8e51947 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -1,6 +1,6 @@ -import { checkDynamicPoolSize } from '../utils' -import { type PoolType, PoolTypes } from '../pool' -import { type ClusterPoolOptions, FixedClusterPool } from './fixed' +import { checkDynamicPoolSize } from '../utils.js' +import { PoolEvents, type PoolType, PoolTypes } from '../pool.js' +import { type ClusterPoolOptions, FixedClusterPool } from './fixed.js' /** * A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers. @@ -34,13 +34,20 @@ export class DynamicClusterPool< super(min, filePath, opts, max) checkDynamicPoolSize( this.minimumNumberOfWorkers, - this.maximumNumberOfWorkers as number + this.maximumNumberOfWorkers ) } /** @inheritDoc */ protected shallCreateDynamicWorker (): boolean { - return !this.full && this.internalBusy() + return (!this.full && this.internalBusy()) || this.empty + } + + /** @inheritDoc */ + protected checkAndEmitDynamicWorkerCreationEvents (): void { + if (this.full) { + this.emitter?.emit(PoolEvents.full, this.info) + } } /** @inheritDoc */