export const buildWorkerChoiceStrategiesPolicy = (
workerChoiceStrategies: Map<WorkerChoiceStrategy, IWorkerChoiceStrategy>
): StrategyPolicy => {
- const policies: StrategyPolicy[] = []
- for (const workerChoiceStrategy of workerChoiceStrategies.values()) {
- policies.push(workerChoiceStrategy.strategyPolicy)
- }
+ const policies: StrategyPolicy[] = Array.from(
+ workerChoiceStrategies,
+ ([_, workerChoiceStrategy]) => workerChoiceStrategy.strategyPolicy
+ )
return {
dynamicWorkerUsage: policies.some(p => p.dynamicWorkerUsage),
dynamicWorkerReady: policies.some(p => p.dynamicWorkerReady)
export const buildWorkerChoiceStrategiesTaskStatisticsRequirements = (
workerChoiceStrategies: Map<WorkerChoiceStrategy, IWorkerChoiceStrategy>
): TaskStatisticsRequirements => {
- const taskStatisticsRequirements: TaskStatisticsRequirements[] = []
- for (const workerChoiceStrategy of workerChoiceStrategies.values()) {
- taskStatisticsRequirements.push(
+ const taskStatisticsRequirements: TaskStatisticsRequirements[] = Array.from(
+ workerChoiceStrategies,
+ ([_, workerChoiceStrategy]) =>
workerChoiceStrategy.taskStatisticsRequirements
- )
- }
+ )
return {
runTime: {
aggregate: taskStatisticsRequirements.some(r => r.runTime.aggregate),
* @returns `true` if the update is successful, `false` otherwise.
*/
public update (workerNodeKey: number): boolean {
- const res: boolean[] = []
- for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) {
- res.push(workerChoiceStrategy.update(workerNodeKey))
- }
- return res.every(r => r)
+ return Array.from(
+ this.workerChoiceStrategies,
+ ([_, workerChoiceStrategy]) => workerChoiceStrategy.update(workerNodeKey)
+ ).every(r => r)
}
/**
* @returns `true` if the removal is successful, `false` otherwise.
*/
public remove (workerNodeKey: number): boolean {
- const res: boolean[] = []
- for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) {
- res.push(workerChoiceStrategy.remove(workerNodeKey))
- }
- return res.every(r => r)
+ return Array.from(
+ this.workerChoiceStrategies,
+ ([_, workerChoiceStrategy]) => workerChoiceStrategy.remove(workerNodeKey)
+ ).every(r => r)
}
/**