X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=docs%2Fapi.md;h=513f62c53a450dc6279e7807fcbd855fc63b525a;hb=HEAD;hp=28e6aad2c3b56bf529890aad889c9029e4b69777;hpb=152e87a8c57c8cbd3a3b437106bcc79c30fcc720;p=poolifier.git diff --git a/docs/api.md b/docs/api.md index 28e6aad2..113d4c12 100644 --- a/docs/api.md +++ b/docs/api.md @@ -6,6 +6,7 @@ - [`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.mapExecute(data, name, transferList)`](#poolmapexecutedata-name-transferlist) - [`pool.start()`](#poolstart) - [`pool.destroy()`](#pooldestroy) - [`pool.hasTaskFunction(name)`](#poolhastaskfunctionname) @@ -45,6 +46,14 @@ This method is available on both pool implementations and returns a promise with the task function execution response. +### `pool.mapExecute(data, name, transferList)` + +`data` Iterable objects that you want to pass to your worker task function implementation. +`name` (optional) A string with the task function name that you want to execute on the worker. Default: `'default'` +`transferList` (optional) An array of transferable objects that you want to transfer to your [`ThreadWorker`](#class-yourworker-extends-threadworkerclusterworker) worker implementation. + +This method is available on both pool implementations and returns a promise with the task function execution responses array. + ### `pool.start()` This method is available on both pool implementations and will start the minimum number of workers. @@ -135,9 +144,10 @@ An object with these properties: - `concurrency` (optional) - The maximum number of tasks that can be executed concurrently on a worker. It must be a positive integer. - `taskStealing` (optional) - Task stealing enablement on idle. - `tasksStealingOnBackPressure` (optional) - Tasks stealing enablement under back pressure. + - `tasksStealingRatio` (optional) - The ratio of worker nodes that can steal tasks from another worker node. It must be a number between 0 and 1. - `tasksFinishedTimeout` (optional) - Queued tasks finished timeout in milliseconds at worker termination. - Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: false, tasksFinishedTimeout: 2000 }` + Default: `{ size: (pool maximum size)^2, concurrency: 1, taskStealing: true, tasksStealingOnBackPressure: true, tasksStealingRatio: 0.6, tasksFinishedTimeout: 2000 }` - `workerOptions` (optional) - An object with the worker options to pass to worker. See [worker_threads](https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options) for more details.