Skip to content

Commit 65b3b9e

Browse files
committed
doc: update FreeEnvironment() notes for sibling Environments
With the FreeEnvironment() fix for sibling Environments and the handle cleanup depth tracked per thread, only the Environment being freed loses JavaScript while FreeEnvironment() runs the shared loop. Callbacks of the other Environments on that loop run their JavaScript as usual. Update embedding.md and the comment in node.h, which still describe JavaScript as disallowed on the whole isolate. Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
1 parent c171538 commit 65b3b9e

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

‎doc/api/embedding.md‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,10 @@ to as `node::Environment`. Each `node::Environment` is associated with:
9595
9696
`node::Environment`s that share a `node::IsolateData` also share its
9797
`uv_loop_t`. `node::FreeEnvironment()` runs that loop until the handles of the
98-
`node::Environment` being freed have closed, and JavaScript execution is
99-
disallowed on the whole `v8::Isolate` while it does, so pending timers, I/O
100-
callbacks and thread pool completions that belong to other `node::Environment`s
101-
on the same loop can run inside that call without being able to call into
102-
JavaScript. `node::Environment`s that are freed independently of one another
103-
should each use their own `uv_loop_t` and `node::IsolateData`, or the embedder
104-
should make sure the others have no pending work when one of them is freed.
98+
`node::Environment` being freed have closed. Timers, I/O callbacks and thread
99+
pool completions of the other `node::Environment`s that become due in those
100+
loop iterations run normally, including their JavaScript; only the
101+
`node::Environment` being freed can no longer call into JavaScript.
105102
106103
In order to set up a `v8::Isolate`, an `v8::ArrayBuffer::Allocator` needs
107104
to be provided. One possible choice is the default Node.js allocator, which

‎src/node.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,8 @@ NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
889889
EmbedderPreloadCallback preload = nullptr);
890890

891891
// Runs `env`'s event loop until its handles have closed, with JavaScript
892-
// execution disallowed on the isolate; see doc/api/embedding.md if that loop
893-
// is shared with other Environments.
892+
// execution disallowed for `env`; see doc/api/embedding.md if that loop is
893+
// shared with other Environments.
894894
NODE_EXTERN void FreeEnvironment(Environment* env);
895895

896896
// Set a callback that is called when process.exit() is called from JS,

0 commit comments

Comments
 (0)