docs: update benchmarks vs. external pools
[poolifier.git] / src / pools / selection-strategies / round-robin-worker-choice-strategy.ts
index be4fe3326b9585c8bd4f7261023cda4fe5af710e..835860930b0d76f54c37d547b73274d9bf7fb175 100644 (file)
@@ -4,6 +4,7 @@ import type { IWorker } from '../worker'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
 import type {
   IWorkerChoiceStrategy,
+  StrategyPolicy,
   WorkerChoiceStrategyOptions
 } from './selection-strategies-types'
 
@@ -11,8 +12,8 @@ import type {
  * Selects the next worker in a round robin fashion.
  *
  * @typeParam Worker - Type of worker which manages the strategy.
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of execution response. This can only be serializable data.
+ * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
+ * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
  */
 export class RoundRobinWorkerChoiceStrategy<
     Worker extends IWorker,
@@ -21,10 +22,10 @@ export class RoundRobinWorkerChoiceStrategy<
   >
   extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
   implements IWorkerChoiceStrategy {
-  /**
-   * Id of the next worker node.
-   */
-  private nextWorkerNodeId: number = 0
+  /** @inheritDoc */
+  public readonly strategyPolicy: StrategyPolicy = {
+    useDynamicWorker: true
+  }
 
   /** @inheritDoc */
   public constructor (
@@ -32,7 +33,7 @@ export class RoundRobinWorkerChoiceStrategy<
     opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
   ) {
     super(pool, opts)
-    this.setRequiredStatistics(this.opts)
+    this.setTaskStatisticsRequirements(this.opts)
   }
 
   /** @inheritDoc */