Skip to content

Commit a8cf886

Browse files
committed
src: shutdown platform from FreePlatform()
There is currently no way to properly do this. PR-URL: #30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 0e57674 commit a8cf886

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/node_platform.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ NodePlatform::NodePlatform(int thread_pool_size,
338338
std::make_shared<WorkerThreadsTaskRunner>(thread_pool_size);
339339
}
340340

341+
NodePlatform::~NodePlatform() {
342+
Shutdown();
343+
}
344+
341345
void NodePlatform::RegisterIsolate(Isolate* isolate, uv_loop_t* loop) {
342346
Mutex::ScopedLock lock(per_isolate_mutex_);
343347
auto delegate = std::make_shared<PerIsolatePlatformData>(isolate, loop);
@@ -381,6 +385,8 @@ void NodePlatform::AddIsolateFinishedCallback(Isolate* isolate,
381385
}
382386

383387
void NodePlatform::Shutdown() {
388+
if (has_shut_down_) return;
389+
has_shut_down_ = true;
384390
worker_thread_task_runner_->Shutdown();
385391

386392
{

src/node_platform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class NodePlatform : public MultiIsolatePlatform {
140140
public:
141141
NodePlatform(int thread_pool_size,
142142
v8::TracingController* tracing_controller);
143-
~NodePlatform() override = default;
143+
~NodePlatform() override;
144144

145145
void DrainTasks(v8::Isolate* isolate) override;
146146
void Shutdown();
@@ -180,6 +180,7 @@ class NodePlatform : public MultiIsolatePlatform {
180180

181181
v8::TracingController* tracing_controller_;
182182
std::shared_ptr<WorkerThreadsTaskRunner> worker_thread_task_runner_;
183+
bool has_shut_down_ = false;
183184
};
184185

185186
} // namespace node

0 commit comments

Comments
 (0)