Bump rollup from 2.42.3 to 2.42.4 (#291)
[poolifier.git] / src / pools / abstract-pool.ts
index ff7413dd52f2f24e32b7359ce0f14af6180cca67..c3f293e78bc693fba6aea17e36c880968ee58443 100644 (file)
@@ -2,6 +2,7 @@ import type {
   MessageValue,
   PromiseWorkerResponseWrapper
 } from '../utility-types'
+import { EMPTY_FUNCTION } from '../utils'
 import { isKillBehavior, KillBehaviors } from '../worker/worker-options'
 import type { IPoolInternal } from './pool-internal'
 import { PoolEmitter, PoolType } from './pool-internal'
@@ -11,13 +12,6 @@ import {
   WorkerChoiceStrategyContext
 } from './selection-strategies'
 
-/**
- * An intentional empty function.
- */
-const EMPTY_FUNCTION: () => void = () => {
-  /* Intentionally empty */
-}
-
 /**
  * Callback invoked if the worker raised an error.
  */
@@ -191,7 +185,7 @@ export abstract class AbstractPool<
         })
         return workerCreated
       },
-      opts.workerChoiceStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN
+      this.opts.workerChoiceStrategy
     )
   }
 
@@ -220,6 +214,8 @@ export abstract class AbstractPool<
   }
 
   private checkPoolOptions (opts: PoolOptions<Worker>): void {
+    this.opts.workerChoiceStrategy =
+      opts.workerChoiceStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN
     this.opts.enableEvents = opts.enableEvents ?? true
   }