src: add API to get MultiIsolatePlatform used in node main thread#20447
src: add API to get MultiIsolatePlatform used in node main thread#20447helloshuangzi wants to merge 3 commits intonodejs:masterfrom
Conversation
src/node.h
Outdated
| NODE_EXTERN void FreeEnvironment(Environment* env); | ||
|
|
||
| // This returns the MultiIsolatePlatform used by node main. | ||
| // If NODE_USE_V8_PLATFORM is not defined, it will return nullptr. |
There was a problem hiding this comment.
Maybe specific that the macro needs to have been defined when Node.js was built, not when the addon is being built?
There was a problem hiding this comment.
Also, what's "node main"? This comment could be expanded a little.
src/node.cc
Outdated
| } | ||
|
|
||
|
|
||
| MultiIsolatePlatform* GetNodeMultiIsolatePlatform() { |
There was a problem hiding this comment.
Redundant name, it's already in the node:: namespace. Just GetMultiIsolatePlatform() or GetMainThreadMultiIsolatePlatform()?
There was a problem hiding this comment.
change it to GetMainThreadMultiIsolatePlatform as a more accurate name.
src/node.h
Outdated
| NODE_EXTERN void FreeEnvironment(Environment* env); | ||
|
|
||
| // This returns the MultiIsolatePlatform used by node main. | ||
| // If NODE_USE_V8_PLATFORM is not defined, it will return nullptr. |
There was a problem hiding this comment.
Also, what's "node main"? This comment could be expanded a little.
e24fb6e to
a115619
Compare
a115619 to
c92af0b
Compare
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM, I think. The commit log should conform to the style guide, though.
src/node.h
Outdated
|
|
||
| // This returns the MultiIsolatePlatform used in the main thread of Node.js. | ||
| // If NODE_USE_V8_PLATFORM haven't been defined when Node.js was built, | ||
| // it would return nullptr. |
There was a problem hiding this comment.
Suggestion: it returns instead of it would return.
|
Thanks for your quick review! |
|
Landed in b00c34c 🎉 And congratulations on the 22,222nd commit to Node |
Add an API to get MultiIsolatePlatform used in node main thread. PR-URL: #20447 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add an API to get MultiIsolatePlatform used in node main thread. PR-URL: #20447 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Notable Changes:
* console:
- make console.table() use colored inspect (TSUYUSATO Kitsune)
#20510
* fs:
- move fs/promises to fs.promises (cjihrig)
#20504
* http:
- added aborted property to request (Robert Nagy)
#20094
* n-api:
- initialize a module via a special symbol (Gabriel Schulhof)
#20161
* src:
- add public API to expose the main V8 Platform (Allen Yonghuang Wang)
#20447
PR-URL: Coming Soon
Add an API to get MultiIsolatePlatform used in node main thread. PR-URL: #20447 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Notable Changes:
* console:
- make console.table() use colored inspect (TSUYUSATO Kitsune)
#20510
* fs:
- move fs/promises to fs.promises (cjihrig)
#20504
* http:
- added aborted property to request (Robert Nagy)
#20094
* n-api:
- initialize a module via a special symbol (Gabriel Schulhof)
#20161
* src:
- add public API to expose the main V8 Platform (Allen Yonghuang Wang)
#20447
PR-URL: #20606
Add an API to get MultiIsolatePlatform used in node main thread. PR-URL: #20447 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Notable Changes:
* console:
- make console.table() use colored inspect (TSUYUSATO Kitsune)
#20510
* fs:
- move fs/promises to fs.promises (cjihrig)
#20504
* http:
- added aborted property to request (Robert Nagy)
#20094
* n-api:
- initialize a module via a special symbol (Gabriel Schulhof)
#20161
* src:
- add public API to expose the main V8 Platform (Allen Yonghuang Wang)
#20447
PR-URL: #20606
Notable Changes:
* console:
- make console.table() use colored inspect (TSUYUSATO Kitsune)
#20510
* fs:
- move fs/promises to fs.promises (cjihrig)
#20504
* http:
- added aborted property to request (Robert Nagy)
#20094
* n-api:
- initialize a module via a special symbol (Gabriel Schulhof)
#20161
* src:
- add public API to expose the main V8 Platform (Allen Yonghuang Wang)
#20447
PR-URL: #20606
This is used to support multi-thread JavaScript by node addon as below.
A node addon can be created to initialize v8 Isolates in separate threads, which is used to run JavaScript in multi-thread. It requires the MultiIsolatePlatform (used in the node main thread) to register those isolates respectively.
As an example you may concern, when we try to re-implement napajs Worker::WorkerThreadFunc by node public APIs, it seems node::GetNodeMultiIsolatePlatform is a missing piece from node API.
#20239 is also an issue about this topic. @fs-eire
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes