From: Jérôme Benoit Date: Fri, 30 Aug 2024 13:22:40 +0000 (+0200) Subject: fix: handle properly small or zero `tasksStealingRatio` X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e45f62158cd1a0e899173a453b1fa43fb8ce7bba;p=poolifier.git fix: handle properly small or zero `tasksStealingRatio` Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index daef9434..098ed233 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -240,8 +240,9 @@ export abstract class AbstractPool< if ( this.cannotStealTask() || this.backPressure || + this.opts.tasksQueueOptions?.tasksStealingRatio === 0 || (this.info.stealingWorkerNodes ?? 0) > - Math.round( + Math.ceil( this.workerNodes.length * // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.opts.tasksQueueOptions!.tasksStealingRatio! @@ -299,8 +300,9 @@ export abstract class AbstractPool< if ( !workerNode.info.continuousStealing && (this.cannotStealTask() || + this.opts.tasksQueueOptions?.tasksStealingRatio === 0 || (this.info.stealingWorkerNodes ?? 0) > - Math.round( + Math.ceil( this.workerNodes.length * // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.opts.tasksQueueOptions!.tasksStealingRatio!