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' into interleaved-weighted-round-robin-worker-choice-strategy
[poolifier.git]
/
src
/
pools
/
selection-strategies
/
less-busy-worker-choice-strategy.ts
diff --git
a/src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
b/src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
index 708c491f63dea4183232c20f5d1c7373d14738ba..f518f9b17f311ad3a8ad262e3b7e5f0be15cc61b 100644
(file)
--- a/
src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
+++ b/
src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
@@
-35,7
+35,7
@@
export class LessBusyWorkerChoiceStrategy<
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.
checkOptions(
opts)
+ this.
setRequiredStatistics(this.
opts)
}
/** @inheritDoc */
}
/** @inheritDoc */
@@
-43,28
+43,33
@@
export class LessBusyWorkerChoiceStrategy<
return true
}
return true
}
+ /** @inheritDoc */
+ public update (): boolean {
+ return true
+ }
+
/** @inheritDoc */
public choose (): number {
/** @inheritDoc */
public choose (): number {
- const freeWorkerNodeKey = this.
pool.
findFreeWorkerNodeKey()
+ const freeWorkerNodeKey = this.findFreeWorkerNodeKey()
if (freeWorkerNodeKey !== -1) {
return freeWorkerNodeKey
}
let minRunTime = Infinity
let lessBusyWorkerNodeKey!: number
if (freeWorkerNodeKey !== -1) {
return freeWorkerNodeKey
}
let minRunTime = Infinity
let lessBusyWorkerNodeKey!: number
- for (const [
index
, workerNode] of this.pool.workerNodes.entries()) {
+ for (const [
workerNodeKey
, workerNode] of this.pool.workerNodes.entries()) {
const workerRunTime = workerNode.tasksUsage.runTime
if (workerRunTime === 0) {
const workerRunTime = workerNode.tasksUsage.runTime
if (workerRunTime === 0) {
- return
index
+ return
workerNodeKey
} else if (workerRunTime < minRunTime) {
minRunTime = workerRunTime
} else if (workerRunTime < minRunTime) {
minRunTime = workerRunTime
- lessBusyWorkerNodeKey =
index
+ lessBusyWorkerNodeKey =
workerNodeKey
}
}
return lessBusyWorkerNodeKey
}
/** @inheritDoc */
}
}
return lessBusyWorkerNodeKey
}
/** @inheritDoc */
- public remove (
workerNodeKey: number
): boolean {
+ public remove (): boolean {
return true
}
}
return true
}
}