import {
DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS,
EMPTY_FUNCTION,
- INITIAL_TASKS_USAGE,
median
} from '../utils'
import { KillBehaviors, isKillBehavior } from '../worker/worker-options'
type WorkerChoiceStrategy
} from './selection-strategies/selection-strategies-types'
import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context'
+import { CircularArray } from '../circular-array'
/**
* Base class that implements some shared logic for all poolifier pools.
this.checkValidWorkerChoiceStrategy(workerChoiceStrategy)
this.opts.workerChoiceStrategy = workerChoiceStrategy
for (const workerNode of this.workerNodes) {
- this.setWorkerNodeTasksUsage(workerNode, INITIAL_TASKS_USAGE)
+ this.setWorkerNodeTasksUsage(workerNode, {
+ run: 0,
+ running: 0,
+ runTime: 0,
+ runTimeHistory: new CircularArray(),
+ avgRunTime: 0,
+ medRunTime: 0,
+ error: 0
+ })
}
this.workerChoiceStrategyContext.setWorkerChoiceStrategy(
workerChoiceStrategy
private pushWorkerNode (worker: Worker): number {
return this.workerNodes.push({
worker,
- tasksUsage: INITIAL_TASKS_USAGE,
+ tasksUsage: {
+ run: 0,
+ running: 0,
+ runTime: 0,
+ runTimeHistory: new CircularArray(),
+ avgRunTime: 0,
+ medRunTime: 0,
+ error: 0
+ },
tasksQueue: []
})
}
-import { CircularArray } from './circular-array'
import type { WorkerChoiceStrategyOptions } from './pools/selection-strategies/selection-strategies-types'
-import type { TasksUsage } from './pools/worker'
/**
* An intentional empty function.
/* Intentionally empty */
})
-/**
- * Initial tasks usage statistics.
- */
-export const INITIAL_TASKS_USAGE: TasksUsage = {
- run: 0,
- running: 0,
- runTime: 0,
- runTimeHistory: new CircularArray(),
- avgRunTime: 0,
- medRunTime: 0,
- error: 0
-}
-
/**
* Default worker choice strategy options.
*/