From c01a81a3fc4e85f0975106c772fe1c6eb38df33a Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Sun, 10 Mar 2019 13:03:44 -0400 Subject: [PATCH] Update documentation and examples for pool.terminate. `pool.terminuate` returns a Promise, but the documentation and examples treated it as if it were synchronous. Fixes #56 --- README.md | 10 +++++----- examples/async.js | 2 +- examples/dedicatedWorker.js | 2 +- examples/offloadFunctions.js | 2 +- examples/proxy.js | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 131c10f5..594a63a3 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ pool.exec(add, [3, 4]) console.error(err); }) .then(function () { - pool.terminate(); // terminate all workers when done + return pool.terminate(); // terminate all workers when done }); ``` @@ -127,7 +127,7 @@ pool.exec('fibonacci', [10]) console.error(err); }) .then(function () { - pool.terminate(); // terminate all workers when done + return pool.terminate(); // terminate all workers when done }); // or run registered functions on the worker via a proxy: @@ -142,7 +142,7 @@ pool.proxy() console.error(err); }) .then(function () { - pool.terminate(); // terminate all workers when done + return pool.terminate(); // terminate all workers when done }); ``` @@ -221,9 +221,9 @@ A worker pool contains the following functions: } ``` -- `Pool.terminate([force: boolean [, timeout: number]])` +- `Pool.terminate([force: boolean [, timeout: number]]) : Promise.<*, Error>`
- If parameter `force` is false (default), workers will finish the tasks they are working on before terminating themselves. When `force` is true, all workers are terminated immediately without finishing running tasks. If `timeout` is provided, worker will be forced to terminal when the timeout expires and the worker has not finished. + If parameter `force` is false (default), workers will finish the tasks they are working on before terminating themselves. When `force` is true, all workers are terminated immediately without finishing running tasks. If `timeout` is provided, worker will be forced to terminate when the timeout expires and the worker has not finished. - `Pool.clear([force: boolean])`
*Deprecated: use `Pool.terminate` instead*
. diff --git a/examples/async.js b/examples/async.js index 35125b88..79f44607 100644 --- a/examples/async.js +++ b/examples/async.js @@ -16,5 +16,5 @@ pool.proxy() console.error(err); }) .then(function () { - pool.terminate(); // terminate all workers when done + return pool.terminate(); // terminate all workers when done }); diff --git a/examples/dedicatedWorker.js b/examples/dedicatedWorker.js index b20a1e81..b9c1723e 100644 --- a/examples/dedicatedWorker.js +++ b/examples/dedicatedWorker.js @@ -12,5 +12,5 @@ pool.exec('fibonacci', [10]) console.error(err); }) .then(function () { - pool.terminate(); // terminate all workers when done + return pool.terminate(); // terminate all workers when done }); diff --git a/examples/offloadFunctions.js b/examples/offloadFunctions.js index 0f461a5b..9467b839 100644 --- a/examples/offloadFunctions.js +++ b/examples/offloadFunctions.js @@ -17,5 +17,5 @@ pool.exec(add, [3, 4]) console.error(err); }) .then(function () { - pool.terminate(); // terminate all workers when done + return pool.terminate(); // terminate all workers when done }); diff --git a/examples/proxy.js b/examples/proxy.js index 7581a473..2c17e08c 100644 --- a/examples/proxy.js +++ b/examples/proxy.js @@ -16,5 +16,5 @@ pool.proxy() console.error(err); }) .then(function () { - pool.terminate(); // terminate all workers when done + return pool.terminate(); // terminate all workers when done });