From dbd73092cca6cabb2b41e18b944656fc43f8757b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 16 Sep 2023 22:38:52 +0200 Subject: [PATCH] refactor: rename pool option tasksStealing to taskStealing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 2 +- docs/api.md | 4 ++-- src/pools/abstract-pool.ts | 4 ++-- src/pools/pool.ts | 4 ++-- tests/pools/abstract/abstract-pool.test.js | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fec036f..29d771c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add `startWorkers` to pool options to whether start the minimum number of workers at pool creation or not. -- Add `tasksStealing` and `tasksStealingOnPressure` to tasks queue options to whether enable tasks stealing or not and whether enable tasks stealing on back pressure or not. +- Add `taskStealing` and `tasksStealingOnPressure` to tasks queue options to whether enable tasks stealing or not and whether enable tasks stealing on back pressure or not. - Continuous internal benchmarking: https://poolifier.github.io/benchmark-results/dev/bench. ## [2.6.44] - 2023-09-08 diff --git a/docs/api.md b/docs/api.md index 5a5ffd49..fa15de88 100644 --- a/docs/api.md +++ b/docs/api.md @@ -102,10 +102,10 @@ An object with these properties: - `size` (optional) - The maximum number of tasks that can be queued on a worker before flagging it as back pressured. It must be a positive integer. - `concurrency` (optional) - The maximum number of tasks that can be executed concurrently on a worker. It must be a positive integer. - - `tasksStealing` (optional) - Tasks stealing enablement. + - `taskStealing` (optional) - Tasks stealing enablement. - `tasksStealingOnBackPressure` (optional) - Tasks stealing enablement on back pressure. - Default: `{ size: (pool maximum size)^2, concurrency: 1, tasksStealing: true, tasksStealingOnBackPressure: true }` + Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: true }` #### `ThreadPoolOptions extends PoolOptions` diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 69df163b..fb1bf845 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -662,7 +662,7 @@ export abstract class AbstractPool< ...{ size: Math.pow(this.maxSize, 2), concurrency: 1, - tasksStealing: true, + taskStealing: true, tasksStealingOnBackPressure: true }, ...tasksQueueOptions @@ -1170,7 +1170,7 @@ export abstract class AbstractPool< // Send the statistics message to worker. this.sendStatisticsMessageToWorker(workerNodeKey) if (this.opts.enableTasksQueue === true) { - if (this.opts.tasksQueueOptions?.tasksStealing === true) { + if (this.opts.tasksQueueOptions?.taskStealing === true) { this.workerNodes[workerNodeKey].onEmptyQueue = this.taskStealingOnEmptyQueue.bind(this) } diff --git a/src/pools/pool.ts b/src/pools/pool.ts index f76be0c0..b5eec21c 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -114,11 +114,11 @@ export interface TasksQueueOptions { */ readonly concurrency?: number /** - * Whether to enable tasks stealing. + * Whether to enable task stealing. * * @defaultValue true */ - readonly tasksStealing?: boolean + readonly taskStealing?: boolean /** * Whether to enable tasks stealing on back pressure. * diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index df109fe1..719acd76 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -239,7 +239,7 @@ describe('Abstract pool test suite', () => { tasksQueueOptions: { concurrency: 2, size: 4, - tasksStealing: true, + taskStealing: true, tasksStealingOnBackPressure: true }, workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED, @@ -635,7 +635,7 @@ describe('Abstract pool test suite', () => { expect(pool.opts.tasksQueueOptions).toStrictEqual({ concurrency: 1, size: 4, - tasksStealing: true, + taskStealing: true, tasksStealingOnBackPressure: true }) pool.enableTasksQueue(true, { concurrency: 2 }) @@ -643,7 +643,7 @@ describe('Abstract pool test suite', () => { expect(pool.opts.tasksQueueOptions).toStrictEqual({ concurrency: 2, size: 4, - tasksStealing: true, + taskStealing: true, tasksStealingOnBackPressure: true }) pool.enableTasksQueue(false) @@ -661,14 +661,14 @@ describe('Abstract pool test suite', () => { expect(pool.opts.tasksQueueOptions).toStrictEqual({ concurrency: 1, size: 4, - tasksStealing: true, + taskStealing: true, tasksStealingOnBackPressure: true }) pool.setTasksQueueOptions({ concurrency: 2 }) expect(pool.opts.tasksQueueOptions).toStrictEqual({ concurrency: 2, size: 4, - tasksStealing: true, + taskStealing: true, tasksStealingOnBackPressure: true }) expect(() => -- 2.34.1