if (
this.cannotStealTask() ||
this.backPressure ||
- this.opts.tasksQueueOptions?.tasksStealingRatio === 0 ||
- (this.info.stealingWorkerNodes ?? 0) >
- Math.ceil(
- this.workerNodes.length *
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.opts.tasksQueueOptions!.tasksStealingRatio!
- )
+ this.isStealingRatioReached()
) {
return
}
}
if (
!workerNode.info.continuousStealing &&
- (this.cannotStealTask() ||
- this.opts.tasksQueueOptions?.tasksStealingRatio === 0 ||
- (this.info.stealingWorkerNodes ?? 0) >
- Math.ceil(
- this.workerNodes.length *
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.opts.tasksQueueOptions!.tasksStealingRatio!
- ))
+ (this.cannotStealTask() || this.isStealingRatioReached())
) {
return
}
})
}
+ private readonly isStealingRatioReached = (): boolean => {
+ return (
+ this.opts.tasksQueueOptions?.tasksStealingRatio === 0 ||
+ (this.info.stealingWorkerNodes ?? 0) >
+ Math.ceil(
+ this.workerNodes.length *
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.opts.tasksQueueOptions!.tasksStealingRatio!
+ )
+ )
+ }
+
/**
* Whether the pool ready event has been emitted or not.
*/