OLD | NEW |
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 "content/renderer/raster_worker_pool.h" | 5 #include "content/renderer/raster_worker_pool.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/threading/thread_restrictions.h" | 8 #include "base/threading/thread_restrictions.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 | 10 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 ScheduleTasksWithLockAcquired(token, graph); | 207 ScheduleTasksWithLockAcquired(token, graph); |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 void RasterWorkerPool::ScheduleTasksWithLockAcquired(cc::NamespaceToken token, | 211 void RasterWorkerPool::ScheduleTasksWithLockAcquired(cc::NamespaceToken token, |
212 cc::TaskGraph* graph) { | 212 cc::TaskGraph* graph) { |
213 DCHECK(token.IsValid()); | 213 DCHECK(token.IsValid()); |
214 DCHECK(!cc::TaskGraphWorkQueue::DependencyMismatch(graph)); | 214 DCHECK(!cc::TaskGraphWorkQueue::DependencyMismatch(graph)); |
215 DCHECK(!shutdown_); | 215 DCHECK(!shutdown_); |
216 | 216 |
| 217 // RasterWorkerPool does not care about categories for now. |
| 218 // TODO(ericrk): Add threads per category and remove this. |
| 219 cc::TaskGraphWorkQueue::UncategorizeTaskGraph(graph); |
| 220 |
217 work_queue_.ScheduleTasks(token, graph); | 221 work_queue_.ScheduleTasks(token, graph); |
218 | 222 |
219 // If there is more work available, wake up worker thread. | 223 // If there is more work available, wake up worker thread. |
220 if (work_queue_.HasReadyToRunTasks()) | 224 if (work_queue_.HasReadyToRunTasks()) |
221 has_ready_to_run_tasks_cv_.Signal(); | 225 has_ready_to_run_tasks_cv_.Signal(); |
222 } | 226 } |
223 | 227 |
224 void RasterWorkerPool::WaitForTasksToFinishRunning(cc::NamespaceToken token) { | 228 void RasterWorkerPool::WaitForTasksToFinishRunning(cc::NamespaceToken token) { |
225 TRACE_EVENT0("cc", "RasterWorkerPool::WaitForTasksToFinishRunning"); | 229 TRACE_EVENT0("cc", "RasterWorkerPool::WaitForTasksToFinishRunning"); |
226 | 230 |
(...skipping 29 matching lines...) Expand all Loading... |
256 cc::Task::Vector* completed_tasks) { | 260 cc::Task::Vector* completed_tasks) { |
257 DCHECK(token.IsValid()); | 261 DCHECK(token.IsValid()); |
258 work_queue_.CollectCompletedTasks(token, completed_tasks); | 262 work_queue_.CollectCompletedTasks(token, completed_tasks); |
259 } | 263 } |
260 | 264 |
261 void RasterWorkerPool::RunTaskWithLockAcquired() { | 265 void RasterWorkerPool::RunTaskWithLockAcquired() { |
262 TRACE_EVENT0("toplevel", "TaskGraphRunner::RunTask"); | 266 TRACE_EVENT0("toplevel", "TaskGraphRunner::RunTask"); |
263 | 267 |
264 lock_.AssertAcquired(); | 268 lock_.AssertAcquired(); |
265 | 269 |
266 auto prioritized_task = work_queue_.GetNextTaskToRun(); | 270 auto prioritized_task = work_queue_.GetNextTaskToRun(0u /* category */); |
267 cc::Task* task = prioritized_task.task; | 271 cc::Task* task = prioritized_task.task; |
268 | 272 |
269 // There may be more work available, so wake up another worker thread. | 273 // There may be more work available, so wake up another worker thread. |
270 if (work_queue_.HasReadyToRunTasks()) | 274 if (work_queue_.HasReadyToRunTasks()) |
271 has_ready_to_run_tasks_cv_.Signal(); | 275 has_ready_to_run_tasks_cv_.Signal(); |
272 | 276 |
273 // Call WillRun() before releasing |lock_| and running task. | 277 // Call WillRun() before releasing |lock_| and running task. |
274 task->WillRun(); | 278 task->WillRun(); |
275 | 279 |
276 { | 280 { |
(...skipping 18 matching lines...) Expand all Loading... |
295 | 299 |
296 // Overridden from cc::Task: | 300 // Overridden from cc::Task: |
297 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { | 301 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { |
298 closure_.Run(); | 302 closure_.Run(); |
299 closure_.Reset(); | 303 closure_.Reset(); |
300 } | 304 } |
301 | 305 |
302 RasterWorkerPool::ClosureTask::~ClosureTask() {} | 306 RasterWorkerPool::ClosureTask::~ClosureTask() {} |
303 | 307 |
304 } // namespace content | 308 } // namespace content |
OLD | NEW |