feat: use monotonic high resolution timer for worker tasks statistics
[poolifier.git] / src / pools / selection-strategies / worker-choice-strategy-context.ts
index 66aafad6bf89b0164d2fab5f89c5aca0a4bea0c5..192cf005805ecfd70c70a337c9a7ac078ce46abb 100644 (file)
@@ -33,8 +33,7 @@ export class WorkerChoiceStrategyContext<
    * Worker choice strategy context constructor.
    *
    * @param pool - The pool instance.
-   * @param createWorkerCallback - The worker creation callback for dynamic pool.
-   * @param workerChoiceStrategy - The worker choice strategy.
+   * @param workerChoiceStrategyType - The worker choice strategy.
    */
   public constructor (
     pool: IPoolInternal<Worker, Data, Response>,
@@ -89,11 +88,10 @@ export class WorkerChoiceStrategyContext<
   public setWorkerChoiceStrategy (
     workerChoiceStrategy: WorkerChoiceStrategy
   ): void {
-    if (this.workerChoiceStrategyType === workerChoiceStrategy) {
-      this.workerChoiceStrategies.get(workerChoiceStrategy)?.reset()
-    } else {
+    if (this.workerChoiceStrategyType !== workerChoiceStrategy) {
       this.workerChoiceStrategyType = workerChoiceStrategy
     }
+    this.workerChoiceStrategies.get(this.workerChoiceStrategyType)?.reset()
   }
 
   /**