doc: improve c++ embedder API doc

normalise the headers, fixup bullet points and
expand `node::IsolateData` scope for clarity.

PR-URL: https://github.com/nodejs/node/pull/55597
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Gireesh Punathil 2024-11-01 09:13:53 +05:30 committed by GitHub
parent a53c0cc7fc
commit 824c149e79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,7 +23,7 @@ a Node.js-specific environment.
The full code can be found [in the Node.js source tree][embedtest.cc].
### Setting up per-process state
### Setting up a per-process state
Node.js requires some per-process state management in order to run:
@ -72,7 +72,7 @@ int main(int argc, char** argv) {
}
```
### Per-instance state
### Setting up a per-instance state
<!-- YAML
changes:
@ -86,11 +86,12 @@ Node.js has a concept of a “Node.js instance”, that is commonly being referr
to as `node::Environment`. Each `node::Environment` is associated with:
* Exactly one `v8::Isolate`, i.e. one JS Engine instance,
* Exactly one `uv_loop_t`, i.e. one event loop, and
* A number of `v8::Context`s, but exactly one main `v8::Context`.
* Exactly one `uv_loop_t`, i.e. one event loop,
* A number of `v8::Context`s, but exactly one main `v8::Context`, and
* One `node::IsolateData` instance that contains information that could be
shared by multiple `node::Environment`s that use the same `v8::Isolate`.
Currently, no testing is performed for this scenario.
shared by multiple `node::Environment`s. The embedder should make sure
that `node::IsolateData` is shared only among `node::Environment`s that
use the same `v8::Isolate`, Node.js does not perform this check.
In order to set up a `v8::Isolate`, an `v8::ArrayBuffer::Allocator` needs
to be provided. One possible choice is the default Node.js allocator, which