}
}
+ private buildTasksQueueOptions (
+ tasksQueueOptions: TasksQueueOptions
+ ): TasksQueueOptions {
+ return {
+ ...{
+ size: Math.pow(this.maxSize, 2),
+ concurrency: 1,
+ taskStealing: true,
+ tasksStealingOnBackPressure: true
+ },
+ ...tasksQueueOptions
+ }
+ }
+
private setTasksQueueSize (size: number): void {
for (const workerNode of this.workerNodes) {
workerNode.tasksQueueBackPressureSize = size
}
}
- private buildTasksQueueOptions (
- tasksQueueOptions: TasksQueueOptions
- ): TasksQueueOptions {
- return {
- ...{
- size: Math.pow(this.maxSize, 2),
- concurrency: 1,
- taskStealing: true,
- tasksStealingOnBackPressure: true
- },
- ...tasksQueueOptions
- }
- }
-
/**
* Whether the pool is full or not.
*
this.workerNodes[workerNodeKey].closeChannel()
this.emitter?.emit(PoolEvents.error, error)
if (
- this.opts.restartWorkerOnError === true &&
this.started &&
- !this.starting
+ !this.starting &&
+ this.opts.restartWorkerOnError === true
) {
if (workerInfo.dynamic) {
this.createAndSetupDynamicWorkerNode()
this.createAndSetupWorkerNode()
}
}
- if (this.opts.enableTasksQueue === true) {
+ if (this.started && this.opts.enableTasksQueue === true) {
this.redistributeQueuedTasks(workerNodeKey)
}
})
)
workerInfo.ready = message.ready as boolean
workerInfo.taskFunctions = message.taskFunctions
- if (this.emitter != null && this.ready) {
- this.emitter.emit(PoolEvents.ready, this.info)
+ if (this.ready) {
+ this.emitter?.emit(PoolEvents.ready, this.info)
}
}