perf: avoid branching on pool type
[poolifier.git] / src / pools / cluster / dynamic.ts
index ce28e421544131e2f3b5efbf762e66b1c8b71103..08ebc75c76a66ba5ca311c2e269988d741ad5aff 100644 (file)
@@ -1,5 +1,5 @@
 import { checkDynamicPoolSize } from '../utils'
-import { type PoolType, PoolTypes } from '../pool'
+import { PoolEvents, type PoolType, PoolTypes } from '../pool'
 import { type ClusterPoolOptions, FixedClusterPool } from './fixed'
 
 /**
@@ -43,6 +43,13 @@ export class DynamicClusterPool<
     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