src: add public API for managing NodePlatform

PR-URL: https://github.com/nodejs/node/pull/16981
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Cheng Zhao 2017-11-13 11:41:20 +09:00 committed by James M Snell
parent 493340f56e
commit 272811247e
2 changed files with 22 additions and 0 deletions

View File

@ -4400,6 +4400,18 @@ void FreeEnvironment(Environment* env) {
}
MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,
v8::TracingController* tracing_controller) {
return new NodePlatform(thread_pool_size, tracing_controller);
}
void FreePlatform(MultiIsolatePlatform* platform) {
delete platform;
}
Local<Context> NewContext(Isolate* isolate,
Local<ObjectTemplate> object_template) {
auto context = Context::New(isolate, nullptr, object_template);

View File

@ -97,6 +97,11 @@
// Forward-declare libuv loop
struct uv_loop_s;
// Forward-declare TracingController, used by CreatePlatform.
namespace v8 {
class TracingController;
}
// Forward-declare these functions now to stop MSVS from becoming
// terminally confused when it's done in node_internals.h
namespace node {
@ -244,6 +249,11 @@ NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data,
NODE_EXTERN void LoadEnvironment(Environment* env);
NODE_EXTERN void FreeEnvironment(Environment* env);
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,
v8::TracingController* tracing_controller);
NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform);
NODE_EXTERN void EmitBeforeExit(Environment* env);
NODE_EXTERN int EmitExit(Environment* env);
NODE_EXTERN void RunAtExit(Environment* env);