From b00c34c16155417d1ddee44430d99ca43a837315 Mon Sep 17 00:00:00 2001 From: Allen Yonghuang Wang Date: Mon, 30 Apr 2018 17:34:05 -0700 Subject: [PATCH] src: add public API to expose the main V8 Platform Add an API to get MultiIsolatePlatform used in node main thread. PR-URL: https://github.com/nodejs/node/pull/20447 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Daniel Bevenius Reviewed-By: Colin Ihrig --- src/node.cc | 5 +++++ src/node.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/node.cc b/src/node.cc index ee114257d5d126..669155a908e2eb 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4425,6 +4425,11 @@ void FreeEnvironment(Environment* env) { } +MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() { + return v8_platform.Platform(); +} + + MultiIsolatePlatform* CreatePlatform( int thread_pool_size, v8::TracingController* tracing_controller) { diff --git a/src/node.h b/src/node.h index ab5d1c120fa007..5a491c1abf5457 100644 --- a/src/node.h +++ b/src/node.h @@ -251,6 +251,11 @@ NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data, NODE_EXTERN void LoadEnvironment(Environment* env); NODE_EXTERN void FreeEnvironment(Environment* env); +// This returns the MultiIsolatePlatform used in the main thread of Node.js. +// If NODE_USE_V8_PLATFORM haven't been defined when Node.js was built, +// it returns nullptr. +NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform(); + NODE_EXTERN MultiIsolatePlatform* CreatePlatform( int thread_pool_size, v8::TracingController* tracing_controller);