From: Jérôme Benoit Date: Sat, 16 Sep 2023 21:46:02 +0000 (+0200) Subject: Merge branch 'master' of github.com:poolifier/poolifier into feature/task-functions X-Git-Tag: v2.7.0~1^2~30 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=5972baf82c740050a6da461a8deb8497fcaa8580;p=poolifier.git Merge branch 'master' of github.com:poolifier/poolifier into feature/task-functions Signed-off-by: Jérôme Benoit --- 5972baf82c740050a6da461a8deb8497fcaa8580 diff --cc CHANGELOG.md index f1857ed7,f40bbb4f..852f5693 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -10,12 -10,13 +10,18 @@@ and this project adheres to [Semantic V ### Changed - Disable publication on GitHub packages registry on release until authentication issue is fixed. +- Rename `listTaskFunctions()` to `listTaskFunctionNames()` in pool and worker API. + +### Added + +- Add `addTaskFunction()`, `removeTaskFunction()`, `setDefaultTaskFunction()` methods to pool API. + ### 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 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 ### Fixed diff --cc docs/api.md index ad8ede83,7939123b..20d10edf --- a/docs/api.md +++ b/docs/api.md @@@ -6,8 -6,9 +6,9 @@@ - [`pool = new FixedThreadPool/FixedClusterPool(numberOfThreads/numberOfWorkers, filePath, opts)`](#pool--new-fixedthreadpoolfixedclusterpoolnumberofthreadsnumberofworkers-filepath-opts) - [`pool = new DynamicThreadPool/DynamicClusterPool(min, max, filePath, opts)`](#pool--new-dynamicthreadpooldynamicclusterpoolmin-max-filepath-opts) - [`pool.execute(data, name, transferList)`](#poolexecutedata-name-transferlist) + - [`pool.start()`](#poolstart) - [`pool.destroy()`](#pooldestroy) - - [`pool.listTaskFunctions()`](#poollisttaskfunctions) + - [`pool.listTaskFunctionNames()`](#poollisttaskfunctionnames) - [`PoolOptions`](#pooloptions) - [`ThreadPoolOptions extends PoolOptions`](#threadpooloptions-extends-pooloptions) - [`ClusterPoolOptions extends PoolOptions`](#clusterpooloptions-extends-pooloptions) diff --cc src/pools/abstract-pool.ts index e122e881,fb1bf845..67618825 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@@ -92,17 -92,6 +92,13 @@@ export abstract class AbstractPool */ protected readonly max?: number + /** + * The task functions added at runtime map: + * - `key`: The task function name. + * - `value`: The task function itself. + */ + private readonly taskFunctions: Map> + - /** - * Whether the pool is starting or not. - */ - private readonly starting: boolean /** * Whether the pool is started or not. */ @@@ -152,12 -145,11 +152,13 @@@ this.setupHook() + this.taskFunctions = new Map>() + - this.starting = true - this.startPool() + this.started = false this.starting = false - this.started = true + if (this.opts.startWorkers === true) { + this.start() + } this.startTimestamp = performance.now() }