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 9b84ee6

Browse filesBrowse files
committed
src: add ability to look up platform based on Environment*
This should eventually remove any necessity to use the global-state `GetMainThreadMultiIsolatePlatform()`. 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 a770a35 commit 9b84ee6
Copy full SHA for 9b84ee6

File tree

Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Collapse file

‎src/api/environment.cc‎

Copy file name to clipboardExpand all lines: src/api/environment.cc
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,14 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() {
474474
return per_process::v8_platform.Platform();
475475
}
476476

477+
MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env) {
478+
return GetMultiIsolatePlatform(env->isolate_data());
479+
}
480+
481+
MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) {
482+
return env->platform();
483+
}
484+
477485
MultiIsolatePlatform* CreatePlatform(
478486
int thread_pool_size,
479487
node::tracing::TracingController* tracing_controller) {
Collapse file

‎src/node.h‎

Copy file name to clipboardExpand all lines: src/node.h
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,14 @@ NODE_EXTERN void FreeEnvironment(Environment* env);
456456
NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
457457

458458
// This returns the MultiIsolatePlatform used in the main thread of Node.js.
459-
// If NODE_USE_V8_PLATFORM haven't been defined when Node.js was built,
459+
// If NODE_USE_V8_PLATFORM has not been defined when Node.js was built,
460460
// it returns nullptr.
461+
// TODO(addaleax): Deprecate in favour of GetMultiIsolatePlatform().
461462
NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform();
463+
// This returns the MultiIsolatePlatform used for an Environment or IsolateData
464+
// instance, if one exists.
465+
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
466+
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);
462467

463468
// Legacy variants of MultiIsolatePlatform::Create().
464469
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(

0 commit comments

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