X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fthread%2Fdynamic.ts;h=d3764c285291407d75b1ee293ece40ebbc8c5dfd;hb=d1c03778bd26af064147055fc21d6701ffefb707;hp=cd9d23253a040f44070da2fe0b0504da31aeb283;hpb=2889bd70182e9e42c75d686ece3c288307e01d4f;p=poolifier.git diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index cd9d2325..d3764c28 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -1,4 +1,4 @@ -import { type PoolType, PoolTypes } from '../pool' +import { PoolEvents, type PoolType, PoolTypes } from '../pool' import { checkDynamicPoolSize } from '../utils' import { FixedThreadPool, type ThreadPoolOptions } from './fixed' @@ -38,6 +38,18 @@ export class DynamicThreadPool< ) } + /** @inheritDoc */ + protected shallCreateDynamicWorker (): boolean { + return !this.full && this.internalBusy() + } + + /** @inheritDoc */ + protected checkAndEmitDynamicWorkerCreationEvents (): void { + if (this.full) { + this.emitter?.emit(PoolEvents.full, this.info) + } + } + /** @inheritDoc */ protected get type (): PoolType { return PoolTypes.dynamic