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

Side by Side Diff: cc/raster/single_thread_task_graph_runner.cc

Issue 1854723002: cc: Simplify task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 "cc/raster/single_thread_task_graph_runner.h" 5 #include "cc/raster/single_thread_task_graph_runner.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 has_namespaces_with_finished_running_tasks_cv_.Wait(); 92 has_namespaces_with_finished_running_tasks_cv_.Wait();
93 93
94 // There may be other namespaces that have finished running tasks, so wake 94 // There may be other namespaces that have finished running tasks, so wake
95 // up another origin thread. 95 // up another origin thread.
96 has_namespaces_with_finished_running_tasks_cv_.Signal(); 96 has_namespaces_with_finished_running_tasks_cv_.Signal();
97 } 97 }
98 } 98 }
99 99
100 void SingleThreadTaskGraphRunner::CollectCompletedTasks( 100 void SingleThreadTaskGraphRunner::CollectCompletedTasks(
101 NamespaceToken token, 101 NamespaceToken token,
102 Task::Vector* completed_tasks) { 102 DependencyTask::Vector* completed_tasks) {
103 TRACE_EVENT0("cc", "SingleThreadTaskGraphRunner::CollectCompletedTasks"); 103 TRACE_EVENT0("cc", "SingleThreadTaskGraphRunner::CollectCompletedTasks");
104 104
105 DCHECK(token.IsValid()); 105 DCHECK(token.IsValid());
106 106
107 { 107 {
108 base::AutoLock lock(lock_); 108 base::AutoLock lock(lock_);
109 work_queue_.CollectCompletedTasks(token, completed_tasks); 109 work_queue_.CollectCompletedTasks(token, completed_tasks);
110 } 110 }
111 } 111 }
112 112
(...skipping 26 matching lines...) Expand all
139 ready_to_run_namespaces.cbegin(), ready_to_run_namespaces.cend(), 139 ready_to_run_namespaces.cbegin(), ready_to_run_namespaces.cend(),
140 [](const std::pair<uint16_t, TaskGraphWorkQueue::TaskNamespace::Vector>& 140 [](const std::pair<uint16_t, TaskGraphWorkQueue::TaskNamespace::Vector>&
141 pair) { return !pair.second.empty(); }); 141 pair) { return !pair.second.empty(); });
142 142
143 if (found == ready_to_run_namespaces.cend()) { 143 if (found == ready_to_run_namespaces.cend()) {
144 return false; 144 return false;
145 } 145 }
146 146
147 const uint16_t category = found->first; 147 const uint16_t category = found->first;
148 auto prioritized_task = work_queue_.GetNextTaskToRun(category); 148 auto prioritized_task = work_queue_.GetNextTaskToRun(category);
149 Task* task = prioritized_task.task; 149 DependencyTask* task = prioritized_task.task;
150 150
151 // Call WillRun() before releasing |lock_| and running task. 151 // Call WillRun() before releasing |lock_| and running task.
152 task->WillRun(); 152 task->WillRun();
153 153
154 { 154 {
155 base::AutoUnlock unlock(lock_); 155 base::AutoUnlock unlock(lock_);
156 task->RunOnWorkerThread(); 156 task->RunOnWorkerThread();
157 } 157 }
158 158
159 // This will mark task as finished running. 159 // This will mark task as finished running.
160 task->DidRun(); 160 task->DidRun();
161 161
162 work_queue_.CompleteTask(prioritized_task); 162 work_queue_.CompleteTask(prioritized_task);
163 163
164 // If namespace has finished running all tasks, wake up origin thread. 164 // If namespace has finished running all tasks, wake up origin thread.
165 if (work_queue_.HasFinishedRunningTasksInNamespace( 165 if (work_queue_.HasFinishedRunningTasksInNamespace(
166 prioritized_task.task_namespace)) 166 prioritized_task.task_namespace))
167 has_namespaces_with_finished_running_tasks_cv_.Signal(); 167 has_namespaces_with_finished_running_tasks_cv_.Signal();
168 168
169 return true; 169 return true;
170 } 170 }
171 171
172 } // namespace cc 172 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698