From 58ba8bfc46c06bf9f75887c18df563d91a1f782c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 8 Feb 2019 19:22:35 +0100 Subject: worker: pre-allocate thread id Allocate a thread id before actually creating the Environment instance. PR-URL: https://github.com/nodejs/node/pull/26011 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ben Noordhuis Reviewed-By: Gireesh Punathil Reviewed-By: Joyee Cheung --- src/env.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/env.h') diff --git a/src/env.h b/src/env.h index 52d0535721..0228b2d9d0 100644 --- a/src/env.h +++ b/src/env.h @@ -618,7 +618,8 @@ class Environment { Environment(IsolateData* isolate_data, v8::Local context, - Flags flags = Flags()); + Flags flags = Flags(), + uint64_t thread_id = kNoThreadId); ~Environment(); void Start(bool start_profiler_idle_notifier); @@ -763,6 +764,9 @@ class Environment { inline bool has_run_bootstrapping_code() const; inline void set_has_run_bootstrapping_code(bool has_run_bootstrapping_code); + static uint64_t AllocateThreadId(); + static constexpr uint64_t kNoThreadId = -1; + inline bool is_main_thread() const; inline bool owns_process_state() const; inline bool owns_inspector() const; -- cgit v1.2.3