perf: avoid branching on pool type
[poolifier.git] / src / pools / cluster / fixed.ts
index d6481be720914c2af14c56bf0182030aa0a456da..b7bf9c1a70bb150d98414571c0820752a8707c9a 100644 (file)
@@ -4,6 +4,11 @@ import { AbstractPool } from '../abstract-pool'
 import { type PoolOptions, type PoolType, PoolTypes } from '../pool'
 import { type WorkerType, WorkerTypes } from '../worker'
 
+/**
+ * Options for a poolifier cluster pool.
+ */
+export type ClusterPoolOptions = PoolOptions<Worker>
+
 /**
  * A cluster pool with a fixed number of workers.
  *
@@ -26,7 +31,7 @@ export class FixedClusterPool<
   public constructor (
     numberOfWorkers: number,
     filePath: string,
-    opts: PoolOptions<Worker> = {},
+    opts: ClusterPoolOptions = {},
     maximumNumberOfWorkers?: number
   ) {
     super(numberOfWorkers, filePath, opts, maximumNumberOfWorkers)
@@ -84,6 +89,11 @@ export class FixedClusterPool<
     this.workerNodes[workerNodeKey].worker.off('message', listener)
   }
 
+  /** @inheritDoc */
+  protected shallCreateDynamicWorker (): boolean {
+    return false
+  }
+
   /** @inheritDoc */
   protected get type (): PoolType {
     return PoolTypes.fixed