-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: use thread_local to declare modpending #28456
src: use thread_local to declare modpending #28456
Conversation
src/node_binding.cc
Outdated
@@ -243,8 +243,7 @@ using v8::Value; | |||
// Globals per process | |||
static node_module* modlist_internal; | |||
static node_module* modlist_linked; | |||
static uv_once_t init_modpending_once = UV_ONCE_INIT; | |||
static uv_key_t thread_local_modpending; | |||
static thread_local struct node_module* thread_local_modpending = 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.
Just node_module*
, no struct (see lines above), and the = nullptr
isn't strictly necessary.
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.
👍 on the node_module*
, but I'd like to keep the initialization because we do a
CHECK_NULL(thread_local_modpending);
later on, and I'm not 100% sure that these variables get initialized on every platform.
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.
OK, looks like the variable oughta get zeroed out: https://en.cppreference.com/w/cpp/language/initialization#Static_initialization
b2ad535
to
72fb292
Compare
The pointer used to hold an incoming dynamically loaded module's `node::node_module` structure needs to be thread-local. So far this was done with `uv_key_set()` and `uv_key_get()`. The language now supports the `thread_local` keyword which makes implementing this a lot cleaner.
72fb292
to
e7b6417
Compare
Let's see if rebasing makes a difference for the CI. |
CI: https://ci.nodejs.org/job/node-test-pull-request/24227/ |
Landed in d3b10f6. |
The pointer used to hold an incoming dynamically loaded module's `node::node_module` structure needs to be thread-local. So far this was done with `uv_key_set()` and `uv_key_get()`. The language now supports the `thread_local` keyword which makes implementing this a lot cleaner. PR-URL: nodejs#28456 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
The pointer used to hold an incoming dynamically loaded module's `node::node_module` structure needs to be thread-local. So far this was done with `uv_key_set()` and `uv_key_get()`. The language now supports the `thread_local` keyword which makes implementing this a lot cleaner. PR-URL: #28456 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
The pointer used to hold an incoming dynamically loaded module's
node::node_module
structure needs to be thread-local. So far this wasdone with
uv_key_set()
anduv_key_get()
. The language now supportsthe
thread_local
keyword which makes implementing this a lot cleaner.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes