perf: remove unneeded class indirection for dynamic pool in worker
[poolifier.git] / src / pools / selection-strategies / abstract-worker-choice-strategy.ts
index 5b526331824be72af5048eb8c76fe26b001a373a..aa370fe433e74065e4155d8612499abef5ec59fb 100644 (file)
@@ -7,7 +7,7 @@ import type {
 } from './selection-strategies-types'
 
 /**
- * Abstract worker choice strategy class.
+ * Worker choice strategy abstract base class.
  *
  * @typeParam Worker - Type of worker which manages the strategy.
  * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
@@ -22,7 +22,8 @@ export abstract class AbstractWorkerChoiceStrategy<
   public readonly isDynamicPool: boolean
   /** {@inheritDoc} */
   public requiredStatistics: RequiredStatistics = {
-    runTime: false
+    runTime: false,
+    avgRunTime: false
   }
 
   /**
@@ -34,6 +35,7 @@ export abstract class AbstractWorkerChoiceStrategy<
     protected readonly pool: IPoolInternal<Worker, Data, Response>
   ) {
     this.isDynamicPool = this.pool.type === PoolType.DYNAMIC
+    this.choose.bind(this)
   }
 
   /** {@inheritDoc} */
@@ -41,4 +43,7 @@ export abstract class AbstractWorkerChoiceStrategy<
 
   /** {@inheritDoc} */
   public abstract choose (): number
+
+  /** {@inheritDoc} */
+  public abstract remove (workerKey: number): boolean
 }