X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fabstract-worker-choice-strategy.ts;h=c364933358528ef3ade54a3cc3dd474cf2c2d9d3;hb=7d0aa97362b17bdac43eea38934aaea3c91363c0;hp=630a2258be49a7ed725f12b1ac555d510dd0e257;hpb=410724041bab556be1385c56f9a32e5030f6f2cf;p=poolifier.git diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index 630a2258..c3649333 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -122,34 +122,17 @@ 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 } /** - * Whether the worker node has back pressure or not (i.e. its tasks queue is full). - * - * @param workerNodeKey - The worker node key. - * @returns `true` if the worker node has back pressure, `false` otherwise. + * Check the next worker node readiness. */ - private 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) - ) + protected checkNextWorkerNodeReadiness (): void { + if (!this.isWorkerNodeReady(this.nextWorkerNodeKey as number)) { + delete this.nextWorkerNodeKey + } } /** @@ -203,15 +186,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()) {