From d293923f776bb52bd76b23a2794e1b23832502a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 16 Sep 2023 22:51:16 +0200 Subject: [PATCH] docs: refine API documentation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 2 +- benchmarks/internal/bench.mjs | 4 ++-- docs/api.md | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d771c2..f40bbb4f 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 `taskStealing` 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 task 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/benchmarks/internal/bench.mjs b/benchmarks/internal/bench.mjs index 1b71538d..891ff9ec 100644 --- a/benchmarks/internal/bench.mjs +++ b/benchmarks/internal/bench.mjs @@ -58,10 +58,10 @@ poolifierSuite .on('cycle', event => { console.info(event.target.toString()) }) - .on('complete', function () { + .on('complete', async function () { console.info( 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name')) ) - fixedThreadPool.destroy() + await fixedThreadPool.destroy() }) .run({ async: true }) diff --git a/docs/api.md b/docs/api.md index fa15de88..7939123b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -59,12 +59,15 @@ This method is available on both pool implementations and returns an array of th An object with these properties: -- `onlineHandler` (optional) - A function that will listen for online event on each worker -- `messageHandler` (optional) - A function that will listen for message event on each worker -- `errorHandler` (optional) - A function that will listen for error event on each worker -- `exitHandler` (optional) - A function that will listen for exit event on each worker -- `startWorkers` (optional) - Start the minimum number of workers at pool creation. - Default: `true` +- `onlineHandler` (optional) - A function that will listen for online event on each worker. + Default: `() => {}` +- `messageHandler` (optional) - A function that will listen for message event on each worker. + Default: `() => {}` +- `errorHandler` (optional) - A function that will listen for error event on each worker. + Default: `() => {}` +- `exitHandler` (optional) - A function that will listen for exit event on each worker. + Default: `() => {}` + - `workerChoiceStrategy` (optional) - The worker choice strategy to use in this pool: - `WorkerChoiceStrategies.ROUND_ROBIN`: Submit tasks to worker in a round robin fashion @@ -90,6 +93,8 @@ An object with these properties: Default: `{ retries: 6, runTime: { median: false }, waitTime: { median: false }, elu: { median: false } }` +- `startWorkers` (optional) - Start the minimum number of workers at pool creation. + Default: `true` - `restartWorkerOnError` (optional) - Restart worker on uncaught error in this pool. Default: `true` - `enableEvents` (optional) - Events emission enablement in this pool. @@ -102,7 +107,7 @@ 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. - - `taskStealing` (optional) - Tasks stealing enablement. + - `taskStealing` (optional) - Task stealing enablement. - `tasksStealingOnBackPressure` (optional) - Tasks stealing enablement on back pressure. Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: true }` -- 2.34.1