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

Side by Side Diff: src/cancelable-task.cc

Issue 2454723002: Reland "[heap] Uncommit marking deque in concurrent task." (Closed)
Patch Set: one more ce fix Created 4 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 unified diff | Download patch
« no previous file with comments | « src/cancelable-task.h ('k') | src/heap/mark-compact.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/cancelable-task.h" 5 #include "src/cancelable-task.h"
6 6
7 #include "src/base/platform/platform.h" 7 #include "src/base/platform/platform.h"
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 30 matching lines...) Expand all
41 41
42 42
43 void CancelableTaskManager::RemoveFinishedTask(uint32_t id) { 43 void CancelableTaskManager::RemoveFinishedTask(uint32_t id) {
44 base::LockGuard<base::Mutex> guard(&mutex_); 44 base::LockGuard<base::Mutex> guard(&mutex_);
45 size_t removed = cancelable_tasks_.erase(id); 45 size_t removed = cancelable_tasks_.erase(id);
46 USE(removed); 46 USE(removed);
47 DCHECK_NE(0, removed); 47 DCHECK_NE(0, removed);
48 cancelable_tasks_barrier_.NotifyOne(); 48 cancelable_tasks_barrier_.NotifyOne();
49 } 49 }
50 50
51 51 CancelableTaskManager::TryAbortResult CancelableTaskManager::TryAbort(
52 bool CancelableTaskManager::TryAbort(uint32_t id) { 52 uint32_t id) {
53 base::LockGuard<base::Mutex> guard(&mutex_); 53 base::LockGuard<base::Mutex> guard(&mutex_);
54 auto entry = cancelable_tasks_.find(id); 54 auto entry = cancelable_tasks_.find(id);
55 if (entry != cancelable_tasks_.end()) { 55 if (entry != cancelable_tasks_.end()) {
56 Cancelable* value = entry->second; 56 Cancelable* value = entry->second;
57 if (value->Cancel()) { 57 if (value->Cancel()) {
58 // Cannot call RemoveFinishedTask here because of recursive locking. 58 // Cannot call RemoveFinishedTask here because of recursive locking.
59 cancelable_tasks_.erase(entry); 59 cancelable_tasks_.erase(entry);
60 cancelable_tasks_barrier_.NotifyOne(); 60 cancelable_tasks_barrier_.NotifyOne();
61 return true; 61 return kTaskAborted;
62 } else {
63 return kTaskRunning;
62 } 64 }
63 } 65 }
64 return false; 66 return kTaskRemoved;
65 } 67 }
66 68
67 69
68 void CancelableTaskManager::CancelAndWait() { 70 void CancelableTaskManager::CancelAndWait() {
69 // Clean up all cancelable fore- and background tasks. Tasks are canceled on 71 // Clean up all cancelable fore- and background tasks. Tasks are canceled on
70 // the way if possible, i.e., if they have not started yet. After each round 72 // the way if possible, i.e., if they have not started yet. After each round
71 // of canceling we wait for the background tasks that have already been 73 // of canceling we wait for the background tasks that have already been
72 // started. 74 // started.
73 base::LockGuard<base::Mutex> guard(&mutex_); 75 base::LockGuard<base::Mutex> guard(&mutex_);
74 canceled_ = true; 76 canceled_ = true;
(...skipping 19 matching lines...) Expand all
94 96
95 CancelableTask::CancelableTask(Isolate* isolate) 97 CancelableTask::CancelableTask(Isolate* isolate)
96 : Cancelable(isolate->cancelable_task_manager()), isolate_(isolate) {} 98 : Cancelable(isolate->cancelable_task_manager()), isolate_(isolate) {}
97 99
98 100
99 CancelableIdleTask::CancelableIdleTask(Isolate* isolate) 101 CancelableIdleTask::CancelableIdleTask(Isolate* isolate)
100 : Cancelable(isolate->cancelable_task_manager()), isolate_(isolate) {} 102 : Cancelable(isolate->cancelable_task_manager()), isolate_(isolate) {}
101 103
102 } // namespace internal 104 } // namespace internal
103 } // namespace v8 105 } // namespace v8
OLDNEW
« no previous file with comments | « src/cancelable-task.h ('k') | src/heap/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698