worker: pre-allocate thread id · nodejs/node@1764aae · GitHub
Skip to content

Commit 1764aae

Browse files
committed
worker: pre-allocate thread id
Allocate a thread id before actually creating the Environment instance. PR-URL: #26011 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 7ab34ae commit 1764aae

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/env.cc

Lines changed: 7 additions & 2 deletions

src/env.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ class Environment {
616616

617617
Environment(IsolateData* isolate_data,
618618
v8::Local<v8::Context> context,
619-
Flags flags = Flags());
619+
Flags flags = Flags(),
620+
uint64_t thread_id = kNoThreadId);
620621
~Environment();
621622

622623
void Start(bool start_profiler_idle_notifier);
@@ -767,6 +768,9 @@ class Environment {
767768
inline bool has_run_bootstrapping_code() const;
768769
inline void set_has_run_bootstrapping_code(bool has_run_bootstrapping_code);
769770

771+
static uint64_t AllocateThreadId();
772+
static constexpr uint64_t kNoThreadId = -1;
773+
770774
inline bool is_main_thread() const;
771775
inline bool owns_process_state() const;
772776
inline bool owns_inspector() const;

src/node_worker.cc

Lines changed: 4 additions & 3 deletions

0 commit comments

Comments
 (0)