perf: avoid branching on pool type
[poolifier.git] / src / pools / thread / dynamic.ts
index cf317ca2db497c66ed303184dcc6747237574af6..d3764c285291407d75b1ee293ece40ebbc8c5dfd 100644 (file)
@@ -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'
 
@@ -43,6 +43,13 @@ export class DynamicThreadPool<
     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