fix: ensure a dynamic scheduled for removal can't be used
[poolifier.git] / src / pools / selection-strategies / abstract-worker-choice-strategy.ts
index 68e09238b204c35e4f6bb87392021f314e3e2923..75c7450d8ccc5f8b73d74b5404f4410f4376a46e 100644 (file)
@@ -122,8 +122,8 @@ export abstract class AbstractWorkerChoiceStrategy<
    * @param workerNodeKey - The worker node key.
    * @returns Whether the worker node is ready or not.
    */
-  private isWorkerNodeReady (workerNodeKey: number): boolean {
-    return this.pool.workerNodes[workerNodeKey]?.info.ready
+  protected isWorkerNodeReady (workerNodeKey: number): boolean {
+    return this.pool.workerNodes[workerNodeKey]?.info.ready ?? false
   }
 
   /**
@@ -132,26 +132,10 @@ export abstract class AbstractWorkerChoiceStrategy<
    * @param workerNodeKey - The worker node key.
    * @returns `true` if the worker node has back pressure, `false` otherwise.
    */
-  private hasWorkerNodeBackPressure (workerNodeKey: number): boolean {
+  protected hasWorkerNodeBackPressure (workerNodeKey: number): boolean {
     return this.pool.hasWorkerNodeBackPressure(workerNodeKey)
   }
 
-  /**
-   * Whether the worker node is eligible or not.
-   * A worker node is eligible if it is ready and does not have back pressure.
-   *
-   * @param workerNodeKey - The worker node key.
-   * @returns `true` if the worker node is eligible, `false` otherwise.
-   * @see {@link isWorkerNodeReady}
-   * @see {@link hasWorkerNodeBackPressure}
-   */
-  protected isWorkerNodeEligible (workerNodeKey: number): boolean {
-    return (
-      this.isWorkerNodeReady(workerNodeKey) &&
-      !this.hasWorkerNodeBackPressure(workerNodeKey)
-    )
-  }
-
   /**
    * Gets the worker node task runtime.
    * If the task statistics require the average runtime, the average runtime is returned.
@@ -203,15 +187,6 @@ export abstract class AbstractWorkerChoiceStrategy<
     this.previousWorkerNodeKey = workerNodeKey ?? this.previousWorkerNodeKey
   }
 
-  /**
-   * Check the next worker node eligibility.
-   */
-  protected checkNextWorkerNodeEligibility (): void {
-    if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
-      delete this.nextWorkerNodeKey
-    }
-  }
-
   protected computeDefaultWorkerWeight (): number {
     let cpusCycleTimeWeight = 0
     for (const cpu of cpus()) {