Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: src/isolate.cc

Issue 1409993012: Add {CancelableTaskManager} to handle {Cancelable} concurrent tasks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: First try: incomplete/blocking Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/cancelable-task.cc ('K') | « src/isolate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index bb0cdf44bb9a878804bf94cff20d58925a8d5d8a..750d92ed2d852ec7a1b2f4383b04c2102c424042 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1880,6 +1880,16 @@ void Isolate::ClearSerializerData() {
void Isolate::Deinit() {
TRACE_ISOLATE(deinit);
+ while (true) {
Hannes Payer (out of office) 2015/11/04 23:19:00 Why the while loop?
+ base::LockGuard<base::Mutex> guard(&isolate_mutex_);
+ for (Cancelable* task : cancelable_tasks_) {
+ if (task->CancelForShutdown()) {
+ cancelable_tasks_.erase(task);
+ }
+ }
+ if (cancelable_tasks_.empty()) break;
+ }
+
debug()->Unload();
FreeThreadResources();
@@ -1920,11 +1930,6 @@ void Isolate::Deinit() {
delete basic_block_profiler_;
basic_block_profiler_ = NULL;
- for (Cancelable* task : cancelable_tasks_) {
- task->Cancel();
- }
- cancelable_tasks_.clear();
-
heap_.TearDown();
logger_->TearDown();
@@ -2799,11 +2804,13 @@ void Isolate::CheckDetachedContextsAfterGC() {
void Isolate::RegisterCancelableTask(Cancelable* task) {
+ base::LockGuard<base::Mutex> guard(&isolate_mutex_);
Hannes Payer (out of office) 2015/11/04 23:19:00 Are these methods not always called from the main
cancelable_tasks_.insert(task);
}
void Isolate::RemoveCancelableTask(Cancelable* task) {
+ base::LockGuard<base::Mutex> guard(&isolate_mutex_);
auto removed = cancelable_tasks_.erase(task);
USE(removed);
DCHECK(removed == 1);
« src/cancelable-task.cc ('K') | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698