X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=cbc24e7d84c65c3313f0e27aea9f927ea7bfe543;hb=660689f017615c233020793967822c31975e5aa0;hp=e61711a8843228e6d4a91724ea00fdf6b4ad8ca4;hpb=2324f8c9233f6e036eee418327c46bb7e71356b9;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index e61711a8..cbc24e7d 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -668,6 +668,20 @@ export abstract class AbstractPool< } } + 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 @@ -700,20 +714,6 @@ export abstract class AbstractPool< } } - 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. * @@ -1118,9 +1118,9 @@ export abstract class AbstractPool< 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() @@ -1128,7 +1128,7 @@ export abstract class AbstractPool< this.createAndSetupWorkerNode() } } - if (this.opts.enableTasksQueue === true) { + if (this.started && this.opts.enableTasksQueue === true) { this.redistributeQueuedTasks(workerNodeKey) } }) @@ -1396,8 +1396,8 @@ export abstract class AbstractPool< ) 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) } }