Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Commit 5d793a4

Browse files
committed
doc: add documentation for workers module
[ci skip]
1 parent 86ae8d1 commit 5d793a4

6 files changed

Lines changed: 411 additions & 0 deletions

File tree

doc/api/_toc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
* [Utilities](util.html)
5151
* [V8](v8.html)
5252
* [VM](vm.html)
53+
* [Worker](worker.html)
5354
* [ZLIB](zlib.html)
5455

5556
<div class="line"></div>

doc/api/domain.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ will be notified, rather than losing the context of the error in the
2525
`process.on('uncaughtException')` handler, or causing the program to
2626
exit immediately with an error code.
2727

28+
*Note*: This module is not available in [`Worker`][]s.
29+
2830
## Warning: Don't Ignore Errors!
2931

3032
<!-- type=misc -->
@@ -505,3 +507,4 @@ rejections.
505507
[`setInterval()`]: timers.html#timers_setinterval_callback_delay_args
506508
[`setTimeout()`]: timers.html#timers_settimeout_callback_delay_args
507509
[`throw`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw
510+
[`Worker`]: #worker_class_worker

doc/api/process.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ added: v0.7.0
412412
The `process.abort()` method causes the Node.js process to exit immediately and
413413
generate a core file.
414414

415+
*Note*: This feature is not available in [`Worker`][] threads.
416+
415417
## process.arch
416418
<!-- YAML
417419
added: v0.5.0
@@ -515,6 +517,8 @@ try {
515517
}
516518
```
517519

520+
*Note*: This feature is not available in [`Worker`][] threads.
521+
518522
## process.config
519523
<!-- YAML
520524
added: v0.7.7
@@ -901,6 +905,8 @@ console.log(process.env.test);
901905
// => 1
902906
```
903907

908+
*Note*: `process.env` is read-only in [`Worker`][] threads.
909+
904910
## process.execArgv
905911
<!-- YAML
906912
added: v0.7.7
@@ -1018,6 +1024,9 @@ If it is necessary to terminate the Node.js process due to an error condition,
10181024
throwing an *uncaught* error and allowing the process to terminate accordingly
10191025
is safer than calling `process.exit()`.
10201026

1027+
*Note*: in [`Worker`][] threads, this function stops the current thread rather than
1028+
the current process.
1029+
10211030
## process.exitCode
10221031
<!-- YAML
10231032
added: v0.11.8
@@ -1185,6 +1194,8 @@ console.log(process.getgroups()); // [ 27, 30, 46, 1000 ]
11851194
*Note*: This function is only available on POSIX platforms (i.e. not Windows
11861195
or Android).
11871196

1197+
*Note*: This feature is not available in [`Worker`][] threads.
1198+
11881199
## process.kill(pid[, signal])
11891200
<!-- YAML
11901201
added: v0.0.6
@@ -1502,6 +1513,7 @@ if (process.getegid && process.setegid) {
15021513
*Note*: This function is only available on POSIX platforms (i.e. not Windows
15031514
or Android).
15041515

1516+
*Note*: This feature is not available in [`Worker`][] threads.
15051517

15061518
## process.seteuid(id)
15071519
<!-- YAML
@@ -1530,6 +1542,8 @@ if (process.geteuid && process.seteuid) {
15301542
*Note*: This function is only available on POSIX platforms (i.e. not Windows
15311543
or Android).
15321544

1545+
*Note*: This feature is not available in [`Worker`][] threads.
1546+
15331547
## process.setgid(id)
15341548
<!-- YAML
15351549
added: v0.1.31
@@ -1557,6 +1571,8 @@ if (process.getgid && process.setgid) {
15571571
*Note*: This function is only available on POSIX platforms (i.e. not Windows
15581572
or Android).
15591573

1574+
*Note*: This feature is not available in [`Worker`][] threads.
1575+
15601576
## process.setgroups(groups)
15611577
<!-- YAML
15621578
added: v0.9.4
@@ -1573,6 +1589,8 @@ The `groups` array can contain numeric group IDs, group names or both.
15731589
*Note*: This function is only available on POSIX platforms (i.e. not Windows
15741590
or Android).
15751591

1592+
*Note*: This feature is not available in [`Worker`][] threads.
1593+
15761594
## process.setuid(id)
15771595
<!-- YAML
15781596
added: v0.1.28
@@ -1598,6 +1616,8 @@ if (process.getuid && process.setuid) {
15981616
*Note*: This function is only available on POSIX platforms (i.e. not Windows
15991617
or Android).
16001618

1619+
*Note*: This feature is not available in [`Worker`][] threads.
1620+
16011621

16021622
## process.stderr
16031623

@@ -1611,6 +1631,8 @@ a [Writable][] stream.
16111631
*Note*: `process.stderr` differs from other Node.js streams in important ways,
16121632
see [note on process I/O][] for more information.
16131633

1634+
*Note*: This feature is not available in [`Worker`][] threads.
1635+
16141636
## process.stdin
16151637

16161638
* {Stream}
@@ -1645,6 +1667,8 @@ For more information see [Stream compatibility][].
16451667
must call `process.stdin.resume()` to read from it. Note also that calling
16461668
`process.stdin.resume()` itself would switch stream to "old" mode.
16471669

1670+
*Note*: This feature is not available in [`Worker`][] threads.
1671+
16481672
## process.stdout
16491673

16501674
* {Stream}
@@ -1663,6 +1687,8 @@ process.stdin.pipe(process.stdout);
16631687
*Note*: `process.stdout` differs from other Node.js streams in important ways,
16641688
see [note on process I/O][] for more information.
16651689

1690+
*Note*: This feature is not available in [`Worker`][] threads.
1691+
16661692
### A note on process I/O
16671693

16681694
`process.stdout` and `process.stderr` differ from other Node.js streams in
@@ -1894,6 +1920,7 @@ cases:
18941920
[`require.main`]: modules.html#modules_accessing_the_main_module
18951921
[`require.resolve()`]: globals.html#globals_require_resolve
18961922
[`setTimeout(fn, 0)`]: timers.html#timers_settimeout_callback_delay_args
1923+
[`Worker`]: worker.html#worker_worker
18971924
[Child Process]: child_process.html
18981925
[Cluster]: cluster.html
18991926
[Duplex]: stream.html#stream_duplex_and_transform_streams

doc/api/vm.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,27 @@ console.log(util.inspect(sandbox));
310310
// { globalVar: 1024 }
311311
```
312312

313+
## vm.moveMessagePortToContext(port, contextifiedSandbox)
314+
<!-- YAML
315+
added: REPLACEME
316+
-->
317+
318+
* `port` {MessagePort}
319+
* `contextifiedSandbox` {Object} A contextified object as returned by the
320+
`vm.createContext()` method.
321+
* Returns: {MessagePort}
322+
323+
Bind a `MessagePort` to a specific VM context. This returns a new `MessagePort`
324+
object, whose prototype and methods act as if they were created in the passed
325+
context. The received messages will also be emitted as objects from the passed
326+
context.
327+
328+
Note that the return instance is *not* an `EventEmitter`; for receiving
329+
messages, the `.onmessage` property can be used.
330+
331+
The `port` object on which this method was called can not be used for sending
332+
or receiving further messages.
333+
313334
## vm.runInDebugContext(code)
314335
<!-- YAML
315336
added: v0.11.14

0 commit comments

Comments
 (0)