From: Jérôme Benoit Date: Fri, 16 Jun 2023 10:54:59 +0000 (+0200) Subject: refactor: simplify condition X-Git-Tag: v2.6.3~22 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7b56f532ef66ecf7adefe979100c0d26f95245d4;p=poolifier.git refactor: simplify condition Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 8466e2ba..9058bed6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ensure no tasks are queued when trying to soft kill a dynamic worker. +### Changed + +- Optimize O(1) queue implementation. + ## [2.6.2] - 2023-06-12 ### Fixed diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 21cfb395..ac4cb31e 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -720,15 +720,14 @@ export abstract class AbstractPool< const currentWorkerNodeKey = this.getWorkerNodeKey(worker) if ( isKillBehavior(KillBehaviors.HARD, message.kill) || - (this.opts.enableTasksQueue === false && - message.kill != null && - this.workerNodes[currentWorkerNodeKey].workerUsage.tasks.executing === - 0) || - (this.opts.enableTasksQueue === true && - message.kill != null && - this.workerNodes[currentWorkerNodeKey].workerUsage.tasks.executing === - 0 && - this.tasksQueueSize(currentWorkerNodeKey) === 0) + (message.kill != null && + ((this.opts.enableTasksQueue === false && + this.workerNodes[currentWorkerNodeKey].workerUsage.tasks + .executing === 0) || + (this.opts.enableTasksQueue === true && + this.workerNodes[currentWorkerNodeKey].workerUsage.tasks + .executing === 0 && + this.tasksQueueSize(currentWorkerNodeKey) === 0))) ) { // Kill message received from the worker: no new tasks are submitted to that worker for a while ( > maxInactiveTime) void (this.destroyWorker(worker) as Promise)