doc,worker: use code markup/markdown in headers
PR-URL: https://github.com/nodejs/node/pull/31086 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
ae4cd76e43
commit
deb0c819e5
@ -53,7 +53,7 @@ When implementing a worker pool, use the [`AsyncResource`][] API to inform
|
|||||||
diagnostic tools (e.g. in order to provide asynchronous stack traces) about the
|
diagnostic tools (e.g. in order to provide asynchronous stack traces) about the
|
||||||
correlation between tasks and their outcomes.
|
correlation between tasks and their outcomes.
|
||||||
|
|
||||||
## worker.isMainThread
|
## `worker.isMainThread`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -74,7 +74,7 @@ if (isMainThread) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## worker.moveMessagePortToContext(port, contextifiedSandbox)
|
## `worker.moveMessagePortToContext(port, contextifiedSandbox)`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v11.13.0
|
added: v11.13.0
|
||||||
-->
|
-->
|
||||||
@ -98,7 +98,7 @@ However, the created `MessagePort` will no longer inherit from
|
|||||||
[`EventEmitter`][], and only [`port.onmessage()`][] can be used to receive
|
[`EventEmitter`][], and only [`port.onmessage()`][] can be used to receive
|
||||||
events using it.
|
events using it.
|
||||||
|
|
||||||
## worker.parentPort
|
## `worker.parentPort`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -129,7 +129,7 @@ if (isMainThread) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## worker.receiveMessageOnPort(port)
|
## `worker.receiveMessageOnPort(port)`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v12.3.0
|
added: v12.3.0
|
||||||
-->
|
-->
|
||||||
@ -157,7 +157,7 @@ console.log(receiveMessageOnPort(port2));
|
|||||||
When this function is used, no `'message'` event will be emitted and the
|
When this function is used, no `'message'` event will be emitted and the
|
||||||
`onmessage` listener will not be invoked.
|
`onmessage` listener will not be invoked.
|
||||||
|
|
||||||
## worker.resourceLimits
|
## `worker.resourceLimits`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v13.2.0
|
added: v13.2.0
|
||||||
-->
|
-->
|
||||||
@ -173,7 +173,7 @@ this matches its values.
|
|||||||
|
|
||||||
If this is used in the main thread, its value is an empty object.
|
If this is used in the main thread, its value is an empty object.
|
||||||
|
|
||||||
## worker.SHARE_ENV
|
## `worker.SHARE_ENV`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v11.14.0
|
added: v11.14.0
|
||||||
-->
|
-->
|
||||||
@ -192,7 +192,7 @@ new Worker('process.env.SET_IN_WORKER = "foo"', { eval: true, env: SHARE_ENV })
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## worker.threadId
|
## `worker.threadId`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -203,7 +203,7 @@ An integer identifier for the current thread. On the corresponding worker object
|
|||||||
(if there is any), it is available as [`worker.threadId`][].
|
(if there is any), it is available as [`worker.threadId`][].
|
||||||
This value is unique for each [`Worker`][] instance inside a single process.
|
This value is unique for each [`Worker`][] instance inside a single process.
|
||||||
|
|
||||||
## worker.workerData
|
## `worker.workerData`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -224,7 +224,7 @@ if (isMainThread) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Class: MessageChannel
|
## Class: `MessageChannel`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -244,7 +244,7 @@ port2.postMessage({ foo: 'bar' });
|
|||||||
// Prints: received { foo: 'bar' } from the `port1.on('message')` listener
|
// Prints: received { foo: 'bar' } from the `port1.on('message')` listener
|
||||||
```
|
```
|
||||||
|
|
||||||
## Class: MessagePort
|
## Class: `MessagePort`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -259,7 +259,7 @@ structured data, memory regions and other `MessagePort`s between different
|
|||||||
With the exception of `MessagePort`s being [`EventEmitter`][]s rather
|
With the exception of `MessagePort`s being [`EventEmitter`][]s rather
|
||||||
than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s.
|
than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s.
|
||||||
|
|
||||||
### Event: 'close'
|
### Event: `'close'`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -281,7 +281,7 @@ port1.postMessage('foobar');
|
|||||||
port1.close();
|
port1.close();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Event: 'message'
|
### Event: `'message'`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -294,7 +294,7 @@ input of [`port.postMessage()`][].
|
|||||||
Listeners on this event will receive a clone of the `value` parameter as passed
|
Listeners on this event will receive a clone of the `value` parameter as passed
|
||||||
to `postMessage()` and no further arguments.
|
to `postMessage()` and no further arguments.
|
||||||
|
|
||||||
### port.close()
|
### `port.close()`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -306,7 +306,7 @@ This method can be called when no further communication will happen over this
|
|||||||
The [`'close'` event][] will be emitted on both `MessagePort` instances that
|
The [`'close'` event][] will be emitted on both `MessagePort` instances that
|
||||||
are part of the channel.
|
are part of the channel.
|
||||||
|
|
||||||
### port.postMessage(value\[, transferList\])
|
### `port.postMessage(value[, transferList])`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -387,7 +387,7 @@ posting without having side effects.
|
|||||||
For more information on the serialization and deserialization mechanisms
|
For more information on the serialization and deserialization mechanisms
|
||||||
behind this API, see the [serialization API of the `v8` module][v8.serdes].
|
behind this API, see the [serialization API of the `v8` module][v8.serdes].
|
||||||
|
|
||||||
### port.ref()
|
### `port.ref()`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -400,7 +400,7 @@ If listeners are attached or removed using `.on('message')`, the port will
|
|||||||
be `ref()`ed and `unref()`ed automatically depending on whether
|
be `ref()`ed and `unref()`ed automatically depending on whether
|
||||||
listeners for the event exist.
|
listeners for the event exist.
|
||||||
|
|
||||||
### port.start()
|
### `port.start()`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -415,7 +415,7 @@ Node.js also diverges in its handling of `.onmessage`. Setting it will
|
|||||||
automatically call `.start()`, but unsetting it will let messages queue up
|
automatically call `.start()`, but unsetting it will let messages queue up
|
||||||
until a new handler is set or the port is discarded.
|
until a new handler is set or the port is discarded.
|
||||||
|
|
||||||
### port.unref()
|
### `port.unref()`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -428,7 +428,7 @@ If listeners are attached or removed using `.on('message')`, the port will
|
|||||||
be `ref()`ed and `unref()`ed automatically depending on whether
|
be `ref()`ed and `unref()`ed automatically depending on whether
|
||||||
listeners for the event exist.
|
listeners for the event exist.
|
||||||
|
|
||||||
## Class: Worker
|
## Class: `Worker`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -503,7 +503,7 @@ if (isMainThread) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### new Worker(filename\[, options\])
|
### `new Worker(filename[, options])`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
changes:
|
changes:
|
||||||
@ -560,7 +560,7 @@ changes:
|
|||||||
* `codeRangeSizeMb` {number} The size of a pre-allocated memory range
|
* `codeRangeSizeMb` {number} The size of a pre-allocated memory range
|
||||||
used for generated code.
|
used for generated code.
|
||||||
|
|
||||||
### Event: 'error'
|
### Event: `'error'`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -570,7 +570,7 @@ added: v10.5.0
|
|||||||
The `'error'` event is emitted if the worker thread throws an uncaught
|
The `'error'` event is emitted if the worker thread throws an uncaught
|
||||||
exception. In that case, the worker will be terminated.
|
exception. In that case, the worker will be terminated.
|
||||||
|
|
||||||
### Event: 'exit'
|
### Event: `'exit'`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -582,7 +582,7 @@ exited by calling [`process.exit()`][], the `exitCode` parameter will be the
|
|||||||
passed exit code. If the worker was terminated, the `exitCode` parameter will
|
passed exit code. If the worker was terminated, the `exitCode` parameter will
|
||||||
be `1`.
|
be `1`.
|
||||||
|
|
||||||
### Event: 'message'
|
### Event: `'message'`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -593,7 +593,7 @@ The `'message'` event is emitted when the worker thread has invoked
|
|||||||
[`require('worker_threads').parentPort.postMessage()`][].
|
[`require('worker_threads').parentPort.postMessage()`][].
|
||||||
See the [`port.on('message')`][] event for more details.
|
See the [`port.on('message')`][] event for more details.
|
||||||
|
|
||||||
### Event: 'online'
|
### Event: `'online'`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -601,7 +601,7 @@ added: v10.5.0
|
|||||||
The `'online'` event is emitted when the worker thread has started executing
|
The `'online'` event is emitted when the worker thread has started executing
|
||||||
JavaScript code.
|
JavaScript code.
|
||||||
|
|
||||||
### worker.postMessage(value\[, transferList\])
|
### `worker.postMessage(value[, transferList])`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -613,7 +613,7 @@ Send a message to the worker that will be received via
|
|||||||
[`require('worker_threads').parentPort.on('message')`][].
|
[`require('worker_threads').parentPort.on('message')`][].
|
||||||
See [`port.postMessage()`][] for more details.
|
See [`port.postMessage()`][] for more details.
|
||||||
|
|
||||||
### worker.ref()
|
### `worker.ref()`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -623,7 +623,7 @@ Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker will
|
|||||||
behavior). If the worker is `ref()`ed, calling `ref()` again will have
|
behavior). If the worker is `ref()`ed, calling `ref()` again will have
|
||||||
no effect.
|
no effect.
|
||||||
|
|
||||||
### worker.resourceLimits
|
### `worker.resourceLimits`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v13.2.0
|
added: v13.2.0
|
||||||
-->
|
-->
|
||||||
@ -639,7 +639,7 @@ this matches its values.
|
|||||||
|
|
||||||
If the worker has stopped, the return value is an empty object.
|
If the worker has stopped, the return value is an empty object.
|
||||||
|
|
||||||
### worker.stderr
|
### `worker.stderr`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -651,7 +651,7 @@ inside the worker thread. If `stderr: true` was not passed to the
|
|||||||
[`Worker`][] constructor, then data will be piped to the parent thread's
|
[`Worker`][] constructor, then data will be piped to the parent thread's
|
||||||
[`process.stderr`][] stream.
|
[`process.stderr`][] stream.
|
||||||
|
|
||||||
### worker.stdin
|
### `worker.stdin`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -662,7 +662,7 @@ If `stdin: true` was passed to the [`Worker`][] constructor, this is a
|
|||||||
writable stream. The data written to this stream will be made available in
|
writable stream. The data written to this stream will be made available in
|
||||||
the worker thread as [`process.stdin`][].
|
the worker thread as [`process.stdin`][].
|
||||||
|
|
||||||
### worker.stdout
|
### `worker.stdout`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -674,7 +674,7 @@ inside the worker thread. If `stdout: true` was not passed to the
|
|||||||
[`Worker`][] constructor, then data will be piped to the parent thread's
|
[`Worker`][] constructor, then data will be piped to the parent thread's
|
||||||
[`process.stdout`][] stream.
|
[`process.stdout`][] stream.
|
||||||
|
|
||||||
### worker.terminate()
|
### `worker.terminate()`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
changes:
|
changes:
|
||||||
@ -692,7 +692,7 @@ Stop all JavaScript execution in the worker thread as soon as possible.
|
|||||||
Returns a Promise for the exit code that is fulfilled when the
|
Returns a Promise for the exit code that is fulfilled when the
|
||||||
[`'exit'` event][] is emitted.
|
[`'exit'` event][] is emitted.
|
||||||
|
|
||||||
### worker.threadId
|
### `worker.threadId`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
@ -703,7 +703,7 @@ An integer identifier for the referenced thread. Inside the worker thread,
|
|||||||
it is available as [`require('worker_threads').threadId`][].
|
it is available as [`require('worker_threads').threadId`][].
|
||||||
This value is unique for each `Worker` instance inside a single process.
|
This value is unique for each `Worker` instance inside a single process.
|
||||||
|
|
||||||
### worker.unref()
|
### `worker.unref()`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v10.5.0
|
added: v10.5.0
|
||||||
-->
|
-->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user