Skip to content

Commit

Permalink
src: shutdown platform from FreePlatform()
Browse files Browse the repository at this point in the history
There is currently no way to properly do this.

Backport-PR-URL: #35241
PR-URL: #30467
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
addaleax committed Sep 23, 2020
1 parent a28c990 commit b8c9048
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/node_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ NodePlatform::NodePlatform(int thread_pool_size,
std::make_shared<WorkerThreadsTaskRunner>(thread_pool_size);
}

NodePlatform::~NodePlatform() {
Shutdown();
}

void NodePlatform::RegisterIsolate(Isolate* isolate, uv_loop_t* loop) {
Mutex::ScopedLock lock(per_isolate_mutex_);
std::shared_ptr<PerIsolatePlatformData> existing = per_isolate_[isolate];
Expand Down Expand Up @@ -362,6 +366,8 @@ void NodePlatform::AddIsolateFinishedCallback(Isolate* isolate,
}

void NodePlatform::Shutdown() {
if (has_shut_down_) return;
has_shut_down_ = true;
worker_thread_task_runner_->Shutdown();

{
Expand Down
3 changes: 2 additions & 1 deletion src/node_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class NodePlatform : public MultiIsolatePlatform {
public:
NodePlatform(int thread_pool_size,
v8::TracingController* tracing_controller);
~NodePlatform() override = default;
~NodePlatform() override;

void DrainTasks(v8::Isolate* isolate) override;
void Shutdown();
Expand Down Expand Up @@ -181,6 +181,7 @@ class NodePlatform : public MultiIsolatePlatform {

v8::TracingController* tracing_controller_;
std::shared_ptr<WorkerThreadsTaskRunner> worker_thread_task_runner_;
bool has_shut_down_ = false;
};

} // namespace node
Expand Down

0 comments on commit b8c9048

Please sign in to comment.