X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=1bba1a55eccdc82a02d6c0849c2413c68b70b9dc;hb=38e795c12f0e9daeff7b025147f36f85f486366e;hp=491444755aafd5076663d14b0c22f6cd79eaf716;hpb=ea7a90d36354a4e1c833271571c6f3eb80428600;p=poolifier.git diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index 49144475..1bba1a55 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -7,14 +7,14 @@ import type { WorkerChoiceStrategy } from './selection-strategies-types' import { WorkerChoiceStrategies } from './selection-strategies-types' -import { SelectionStrategiesUtils } from './selection-strategies-utils' +import { getWorkerChoiceStrategy } from './selection-strategies-utils' /** * The worker choice strategy context. * - * @template Worker Type of worker. - * @template Data Type of data sent to the worker. This can only be serializable data. - * @template Response Type of response of execution. This can only be serializable data. + * @typeParam Worker - Type of worker. + * @typeParam Data - Type of data sent to the worker. This can only be serializable data. + * @typeParam Response - Type of response of execution. This can only be serializable data. */ export class WorkerChoiceStrategyContext< Worker extends IPoolWorker, @@ -26,13 +26,13 @@ export class WorkerChoiceStrategyContext< /** * Worker choice strategy context constructor. * - * @param pool The pool instance. - * @param createDynamicallyWorkerCallback The worker creation callback for dynamic pool. - * @param workerChoiceStrategy The worker choice strategy. + * @param pool - The pool instance. + * @param createDynamicallyWorkerCallback - The worker creation callback for dynamic pool. + * @param workerChoiceStrategy - The worker choice strategy. */ public constructor ( private readonly pool: IPoolInternal, - private createDynamicallyWorkerCallback: () => Worker, + private readonly createDynamicallyWorkerCallback: () => Worker, workerChoiceStrategy: WorkerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN ) { this.setWorkerChoiceStrategy(workerChoiceStrategy) @@ -41,7 +41,7 @@ export class WorkerChoiceStrategyContext< /** * Gets the worker choice strategy instance specific to the pool type. * - * @param workerChoiceStrategy The worker choice strategy. + * @param workerChoiceStrategy - The worker choice strategy. * @returns The worker choice strategy instance for the pool type. */ private getPoolWorkerChoiceStrategy ( @@ -54,10 +54,7 @@ export class WorkerChoiceStrategyContext< workerChoiceStrategy ) } - return SelectionStrategiesUtils.getWorkerChoiceStrategy( - this.pool, - workerChoiceStrategy - ) + return getWorkerChoiceStrategy(this.pool, workerChoiceStrategy) } /** @@ -72,15 +69,14 @@ export class WorkerChoiceStrategyContext< /** * Sets the worker choice strategy to use in the context. * - * @param workerChoiceStrategy The worker choice strategy to set. + * @param workerChoiceStrategy - The worker choice strategy to set. */ public setWorkerChoiceStrategy ( workerChoiceStrategy: WorkerChoiceStrategy ): void { - this.workerChoiceStrategy?.resetStatistics() - this.workerChoiceStrategy = this.getPoolWorkerChoiceStrategy( - workerChoiceStrategy - ) + this.workerChoiceStrategy?.reset() + this.workerChoiceStrategy = + this.getPoolWorkerChoiceStrategy(workerChoiceStrategy) } /**