repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #747 from poolifier/multiple-functions
[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 d98732d66882a66e961a04dc49e4241ae5db6e7c..10fc3bf761f4908d8b1dd402f2ee2161310665f7 100644
(file)
--- a/
src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
+++ b/
src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
@@
-1,8
+1,11
@@
+import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils'
+import type { IPool } from '../pool'
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'
/**
@@
-10,7
+13,7
@@
import type {
*
* @typeParam Worker - Type of worker which manages the strategy.
* @typeParam Data - Type of data sent to the worker. This can only be serializable data.
*
* @typeParam Worker - Type of worker which manages the strategy.
* @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.
+ * @typeParam Response - Type of
execution response
. This can only be serializable data.
*/
export class LessBusyWorkerChoiceStrategy<
Worker extends IWorker,
*/
export class LessBusyWorkerChoiceStrategy<
Worker extends IWorker,
@@
-26,6
+29,15
@@
export class LessBusyWorkerChoiceStrategy<
medRunTime: false
}
medRunTime: false
}
+ /** @inheritDoc */
+ public constructor (
+ pool: IPool<Worker, Data, Response>,
+ opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
+ ) {
+ super(pool, opts)
+ this.checkOptions(this.opts)
+ }
+
/** @inheritDoc */
public reset (): boolean {
return true
/** @inheritDoc */
public reset (): boolean {
return true
@@
-33,7
+45,7
@@
export class LessBusyWorkerChoiceStrategy<
/** @inheritDoc */
public choose (): number {
/** @inheritDoc */
public choose (): number {
- const freeWorkerNodeKey = this.
pool.
findFreeWorkerNodeKey()
+ const freeWorkerNodeKey = this.findFreeWorkerNodeKey()
if (freeWorkerNodeKey !== -1) {
return freeWorkerNodeKey
}
if (freeWorkerNodeKey !== -1) {
return freeWorkerNodeKey
}