GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: cleanup per-isolate state on platform on isolate unregister · nodejs/node@de7403f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_platform.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_platform.cc‎

Copy file name to clipboardExpand all lines: src/node_platform.cc
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ void PerIsolatePlatformData::PostIdleTask(std::unique_ptr<v8::IdleTask> task) {
8282
}
8383

8484
void PerIsolatePlatformData::PostTask(std::unique_ptr<Task> task) {
85+
CHECK_NE(flush_tasks_, nullptr);
8586
foreground_tasks_.Push(std::move(task));
8687
uv_async_send(flush_tasks_);
8788
}
8889

8990
void PerIsolatePlatformData::PostDelayedTask(
9091
std::unique_ptr<Task> task, double delay_in_seconds) {
92+
CHECK_NE(flush_tasks_, nullptr);
9193
std::unique_ptr<DelayedTask> delayed(new DelayedTask());
9294
delayed->task = std::move(task);
9395
delayed->platform_data = shared_from_this();
@@ -97,13 +99,21 @@ void PerIsolatePlatformData::PostDelayedTask(
9799
}
98100

99101
PerIsolatePlatformData::~PerIsolatePlatformData() {
102+
Shutdown();
103+
}
104+
105+
void PerIsolatePlatformData::Shutdown() {
106+
if (flush_tasks_ == nullptr)
107+
return;
108+
100109
while (FlushForegroundTasksInternal()) {}
101110
CancelPendingDelayedTasks();
102111

103112
uv_close(reinterpret_cast<uv_handle_t*>(flush_tasks_),
104113
[](uv_handle_t* handle) {
105114
delete reinterpret_cast<uv_async_t*>(handle);
106115
});
116+
flush_tasks_ = nullptr;
107117
}
108118

109119
void PerIsolatePlatformData::ref() {
@@ -144,6 +154,7 @@ void NodePlatform::UnregisterIsolate(IsolateData* isolate_data) {
144154
std::shared_ptr<PerIsolatePlatformData> existing = per_isolate_[isolate];
145155
CHECK(existing);
146156
if (existing->unref() == 0) {
157+
existing->Shutdown();
147158
per_isolate_.erase(isolate);
148159
}
149160
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.