-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: add API to get MultiIsolatePlatform used in node main thread #20447
src: add API to get MultiIsolatePlatform used in node main thread #20447
Conversation
src/node.h
Outdated
@@ -251,6 +251,10 @@ NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data, | |||
NODE_EXTERN void LoadEnvironment(Environment* env); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what's "node main"? This comment could be expanded a little.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/node.cc
Outdated
@@ -4425,6 +4425,11 @@ void FreeEnvironment(Environment* env) { | |||
} | |||
|
|||
|
|||
MultiIsolatePlatform* GetNodeMultiIsolatePlatform() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant name, it's already in the node::
namespace. Just GetMultiIsolatePlatform()
or GetMainThreadMultiIsolatePlatform()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change it to GetMainThreadMultiIsolatePlatform as a more accurate name.
src/node.h
Outdated
@@ -251,6 +251,10 @@ NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data, | |||
NODE_EXTERN void LoadEnvironment(Environment* env); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what's "node main"? This comment could be expanded a little.
e24fb6e
to
a115619
Compare
a115619
to
c92af0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I think. The commit log should conform to the style guide, though.
src/node.h
Outdated
@@ -251,6 +251,11 @@ NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data, | |||
NODE_EXTERN void LoadEnvironment(Environment* env); | |||
NODE_EXTERN void FreeEnvironment(Environment* env); | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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