From: Jérôme Benoit Date: Fri, 18 Aug 2023 22:46:57 +0000 (+0200) Subject: refactor: move back pressure event emission in the helper X-Git-Tag: v2.6.30~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=cb9b167557f9a903021bca1c7aba9fc9b24ae1b1;p=poolifier.git refactor: move back pressure event emission in the helper Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index dc1fc53f..7ed6ab03 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1229,6 +1229,9 @@ export abstract class AbstractPool< if (this.type === PoolTypes.dynamic && this.full) { this.emitter.emit(PoolEvents.full, this.info) } + if (this.hasBackPressure()) { + this.emitter.emit(PoolEvents.backPressure, this.info) + } } } @@ -1309,11 +1312,7 @@ export abstract class AbstractPool< } private enqueueTask (workerNodeKey: number, task: Task): number { - const tasksQueueSize = this.workerNodes[workerNodeKey].enqueueTask(task) - if (this.hasBackPressure()) { - this.emitter?.emit(PoolEvents.backPressure, this.info) - } - return tasksQueueSize + return this.workerNodes[workerNodeKey].enqueueTask(task) } private dequeueTask (workerNodeKey: number): Task | undefined {