Skip to content

Commit

Permalink
Update documentation and examples for pool.terminate.
Browse files Browse the repository at this point in the history
`pool.terminuate` returns a Promise, but the documentation and examples
treated it as if it were synchronous.

Fixes josdejong#56
  • Loading branch information
mramato committed Mar 10, 2019
1 parent da0c602 commit c01a81a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -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
});
```

Expand Down Expand Up @@ -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:
Expand All @@ -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
});
```

Expand Down Expand Up @@ -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>`<br>

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])`<br>
*Deprecated: use `Pool.terminate` instead*<br>.
Expand Down
2 changes: 1 addition & 1 deletion examples/async.js
Expand Up @@ -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
});
2 changes: 1 addition & 1 deletion examples/dedicatedWorker.js
Expand Up @@ -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
});
2 changes: 1 addition & 1 deletion examples/offloadFunctions.js
Expand Up @@ -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
});
2 changes: 1 addition & 1 deletion examples/proxy.js
Expand Up @@ -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
});

0 comments on commit c01a81a

Please sign in to comment.