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

Unified Diff: src/cancelable-task.cc

Issue 2615603002: Implement async AbortAll for the compiler dispatcher (Closed)
Patch Set: updates Created 3 years, 11 months 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
« no previous file with comments | « src/cancelable-task.h ('k') | src/compiler-dispatcher/compiler-dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cancelable-task.cc
diff --git a/src/cancelable-task.cc b/src/cancelable-task.cc
index b712d98877ce930946bd8ceb4754bf4fe403ef8f..b0387f4dc05b55f4345bd415ab334e9e72f94651 100644
--- a/src/cancelable-task.cc
+++ b/src/cancelable-task.cc
@@ -93,6 +93,24 @@ void CancelableTaskManager::CancelAndWait() {
}
}
+CancelableTaskManager::TryAbortResult CancelableTaskManager::TryAbortAll() {
+ // Clean up all cancelable fore- and background tasks. Tasks are canceled on
+ // the way if possible, i.e., if they have not started yet.
+ base::LockGuard<base::Mutex> guard(&mutex_);
+
+ if (cancelable_tasks_.empty()) return kTaskRemoved;
+
+ for (auto it = cancelable_tasks_.begin(); it != cancelable_tasks_.end();) {
+ if (it->second->Cancel()) {
+ it = cancelable_tasks_.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+ return cancelable_tasks_.empty() ? kTaskAborted : kTaskRunning;
+}
+
CancelableTask::CancelableTask(Isolate* isolate)
: CancelableTask(isolate, isolate->cancelable_task_manager()) {}
« no previous file with comments | « src/cancelable-task.h ('k') | src/compiler-dispatcher/compiler-dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698