Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e809a5c

Browse filesBrowse files
committed
src: associate is_main_thread() with worker_context()
In our codebase, the assumption generally is that `!is_main_thread()` means that the current Environment belongs to a Node.js Worker thread. Backport-PR-URL: #35241 PR-URL: #30467 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent b7350e8 commit e809a5c
Copy full SHA for e809a5c

File tree

Expand file treeCollapse file tree

4 files changed

+3
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+3
-6
lines changed
Open diff view settings
Collapse file

‎src/api/environment.cc‎

Copy file name to clipboardExpand all lines: src/api/environment.cc
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
332332
context,
333333
args,
334334
exec_args,
335-
static_cast<Environment::Flags>(Environment::kIsMainThread |
336-
Environment::kOwnsProcessState |
335+
static_cast<Environment::Flags>(Environment::kOwnsProcessState |
337336
Environment::kOwnsInspector));
338337
env->InitializeLibuv(per_process::v8_is_profiling);
339338
if (env->RunBootstrapping().IsEmpty()) {
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ inline void Environment::set_has_serialized_options(bool value) {
854854
}
855855

856856
inline bool Environment::is_main_thread() const {
857-
return flags_ & kIsMainThread;
857+
return worker_context() == nullptr;
858858
}
859859

860860
inline bool Environment::owns_process_state() const {
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,6 @@ class Environment : public MemoryRetainer {
876876

877877
enum Flags {
878878
kNoFlags = 0,
879-
kIsMainThread = 1 << 0,
880879
kOwnsProcessState = 1 << 1,
881880
kOwnsInspector = 1 << 2,
882881
};
Collapse file

‎src/node_main_instance.cc‎

Copy file name to clipboardExpand all lines: src/node_main_instance.cc
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ NodeMainInstance::CreateMainEnvironment(int* exit_code) {
204204
context,
205205
args_,
206206
exec_args_,
207-
static_cast<Environment::Flags>(Environment::kIsMainThread |
208-
Environment::kOwnsProcessState |
207+
static_cast<Environment::Flags>(Environment::kOwnsProcessState |
209208
Environment::kOwnsInspector)) };
210209
env->InitializeLibuv(per_process::v8_is_profiling);
211210
env->InitializeDiagnostics();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.