summaryrefslogtreecommitdiff
path: root/doc/api/worker_threads.md
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-01-08 15:18:19 -0800
committerRich Trott <rtrott@gmail.com>2019-01-11 11:09:22 -0800
commit1415d579a9dcebf669c12a1398bfb35fa0190047 (patch)
tree04698a6c53b9ef64c20c708adccb226980884f5c /doc/api/worker_threads.md
parent906db44ccd316be7ebb643c1e1ae2d666c7aa85f (diff)
downloadandroid-node-v8-1415d579a9dcebf669c12a1398bfb35fa0190047.tar.gz
android-node-v8-1415d579a9dcebf669c12a1398bfb35fa0190047.tar.bz2
android-node-v8-1415d579a9dcebf669c12a1398bfb35fa0190047.zip
doc,worker: revise worker_threads.md
Rewrite worker_threads introductory material focusing on simpler and shorter sentences. PR-URL: https://github.com/nodejs/node/pull/25402 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'doc/api/worker_threads.md')
-rw-r--r--doc/api/worker_threads.md24
1 files changed, 11 insertions, 13 deletions
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md
index 82fb46e017..5cc74e1bc9 100644
--- a/doc/api/worker_threads.md
+++ b/doc/api/worker_threads.md
@@ -4,21 +4,20 @@
> Stability: 1 - Experimental
-The `worker` module provides a way to create multiple environments running
-on independent threads, and to create message channels between them. It
-can be accessed using:
+The `worker_threads` module enables the use of threads with message channels
+between them. To access it:
```js
const worker = require('worker_threads');
```
-Workers are useful for performing CPU-intensive JavaScript operations; do not
-use them for I/O, since Node.js’s built-in mechanisms for performing operations
-asynchronously already treat it more efficiently than Worker threads can.
+Workers (threads) are useful for performing CPU-intensive JavaScript operations.
+They will not help much with I/O-intensive work. Node.js’s built-in asynchronous
+I/O operations are more efficient than Workers can be.
-Workers, unlike child processes or when using the `cluster` module, can also
-share memory efficiently by transferring `ArrayBuffer` instances or sharing
-`SharedArrayBuffer` instances between them.
+Unlike `child_process` or `cluster`, `worker_threads` can share memory. They do
+so by transferring `ArrayBuffer` instances or sharing `SharedArrayBuffer`
+instances.
```js
const {
@@ -46,10 +45,9 @@ if (isMainThread) {
}
```
-Note that this example spawns a Worker thread for each `parse` call.
-In practice, it is strongly recommended to use a pool of Workers for these
-kinds of tasks, since the overhead of creating Workers would likely exceed the
-benefit of handing the work off to it.
+The above example spawns a Worker thread for each `parse()` call. In actual
+practice, use a pool of Workers instead for these kinds of tasks. Otherwise, the
+overhead of creating Workers would likely exceed their benefit.
## worker.isMainThread
<!-- YAML