repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of github.com:poolifier/poolifier
[poolifier.git]
/
src
/
pools
/
selection-strategies
/
weighted-round-robin-worker-choice-strategy.ts
diff --git
a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
index 1bdc02fb189fcf5f21676af2593f2c24854c99dd..f4bac5d76c4e3b669bb5720b99c03b07eabc577d 100644
(file)
--- a/
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
+++ b/
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
@@
-1,11
+1,12
@@
import { cpus } from 'node:os'
import { cpus } from 'node:os'
-import type { IPoolInternal } from '../pool-internal'
import type { IWorker } from '../worker'
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
import type { IWorker } from '../worker'
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- RequiredStatistics
+ RequiredStatistics,
+ WorkerChoiceStrategyOptions
} from './selection-strategies-types'
} from './selection-strategies-types'
+import type { IPool } from '../pool'
/**
* Virtual task runtime.
/**
* Virtual task runtime.
@@
-57,9
+58,13
@@
export class WeightedRoundRobinWorkerChoiceStrategy<
* Constructs a worker choice strategy that selects with a weighted round robin scheduling algorithm.
*
* @param pool - The pool instance.
* Constructs a worker choice strategy that selects with a weighted round robin scheduling algorithm.
*
* @param pool - The pool instance.
+ * @param opts - The worker choice strategy options.
*/
*/
- public constructor (pool: IPoolInternal<Worker, Data, Response>) {
- super(pool)
+ public constructor (
+ pool: IPool<Worker, Data, Response>,
+ opts?: WorkerChoiceStrategyOptions
+ ) {
+ super(pool, opts)
this.defaultWorkerWeight = this.computeWorkerWeight()
this.initWorkersTaskRunTime()
}
this.defaultWorkerWeight = this.computeWorkerWeight()
this.initWorkersTaskRunTime()
}
@@
-146,7
+151,9
@@
export class WeightedRoundRobinWorkerChoiceStrategy<
}
private getWorkerVirtualTaskRunTime (workerNodeKey: number): number {
}
private getWorkerVirtualTaskRunTime (workerNodeKey: number): number {
- return this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
+ return this.requiredStatistics.medRunTime
+ ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime
+ : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
}
private computeWorkerWeight (): number {
}
private computeWorkerWeight (): number {