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); |