mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: add unique_ptr equivalent of CreatePlatform
This makes this bit of the embedder situation a bit easier to use. PR-URL: https://github.com/nodejs/node/pull/30467 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
@@ -490,13 +490,20 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() {
|
||||
MultiIsolatePlatform* CreatePlatform(
|
||||
int thread_pool_size,
|
||||
node::tracing::TracingController* tracing_controller) {
|
||||
return new NodePlatform(thread_pool_size, tracing_controller);
|
||||
return MultiIsolatePlatform::Create(thread_pool_size, tracing_controller)
|
||||
.release();
|
||||
}
|
||||
|
||||
void FreePlatform(MultiIsolatePlatform* platform) {
|
||||
delete platform;
|
||||
}
|
||||
|
||||
std::unique_ptr<MultiIsolatePlatform> MultiIsolatePlatform::Create(
|
||||
int thread_pool_size,
|
||||
node::tracing::TracingController* tracing_controller) {
|
||||
return std::make_unique<NodePlatform>(thread_pool_size, tracing_controller);
|
||||
}
|
||||
|
||||
MaybeLocal<Object> GetPerContextExports(Local<Context> context) {
|
||||
Isolate* isolate = context->GetIsolate();
|
||||
EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
@@ -316,6 +316,10 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform {
|
||||
virtual void AddIsolateFinishedCallback(v8::Isolate* isolate,
|
||||
void (*callback)(void*),
|
||||
void* data) = 0;
|
||||
|
||||
static std::unique_ptr<MultiIsolatePlatform> Create(
|
||||
int thread_pool_size,
|
||||
node::tracing::TracingController* tracing_controller = nullptr);
|
||||
};
|
||||
|
||||
enum IsolateSettingsFlags {
|
||||
@@ -467,6 +471,7 @@ NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
|
||||
// it returns nullptr.
|
||||
NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform();
|
||||
|
||||
// Legacy variants of MultiIsolatePlatform::Create().
|
||||
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
|
||||
int thread_pool_size,
|
||||
node::tracing::TracingController* tracing_controller);
|
||||
|
||||
Reference in New Issue
Block a user