From: Jérôme Benoit Date: Thu, 10 Aug 2023 23:38:32 +0000 (+0200) Subject: fix: fix pool busyness semantic with task queueing enabled X-Git-Tag: v2.6.23~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3d76750ac8dacd95003ca89cf9542c3b2a014b8c;p=poolifier.git fix: fix pool busyness semantic with task queueing enabled Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 987e0e8a..8761941e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,16 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [2.6.22] - 2023-08-10 +### Fixed -## Changed +- Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker. -- Structure markdown documentation (PR #811). +### Added + +- HTTP client pool examples: fetch, node-fetch and axios with multiple task functions. +- HTTP server pool examples: express. + +## [2.6.22] - 2023-08-10 -## Fixed +### Fixed - Add missing `types` field to package.json `exports`. +### Changed + +- Structure markdown documentation (PR #811). + ## [2.6.21] - 2023-08-03 ### Changed diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index aec731a5..91cb5fac 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -615,17 +615,28 @@ export abstract class AbstractPool< protected abstract get busy (): boolean /** - * Whether worker nodes are executing at least one task. + * Whether worker nodes are executing concurrently their tasks quota or not. * * @returns Worker nodes busyness boolean status. */ protected internalBusy (): boolean { - return ( - this.workerNodes.findIndex( - workerNode => - workerNode.info.ready && workerNode.usage.tasks.executing === 0 - ) === -1 - ) + if (this.opts.enableTasksQueue === true) { + return ( + this.workerNodes.findIndex( + workerNode => + workerNode.info.ready && + workerNode.usage.tasks.executing < + (this.opts.tasksQueueOptions?.concurrency as number) + ) === -1 + ) + } else { + return ( + this.workerNodes.findIndex( + workerNode => + workerNode.info.ready && workerNode.usage.tasks.executing === 0 + ) === -1 + ) + } } /** @inheritDoc */