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

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

Issue 1489233003: TaskGraphRunner Group support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor
Patch Set: feedback Created 5 years 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/synchronous_task_graph_runner.h" 5 #include "cc/raster/synchronous_task_graph_runner.h"
6 6
7 #include "base/threading/simple_thread.h" 7 #include "base/threading/simple_thread.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 #include "cc/raster/task_category.h"
10 11
11 namespace cc { 12 namespace cc {
12 13
13 SynchronousTaskGraphRunner::SynchronousTaskGraphRunner() {} 14 SynchronousTaskGraphRunner::SynchronousTaskGraphRunner() {}
14 15
15 SynchronousTaskGraphRunner::~SynchronousTaskGraphRunner() { 16 SynchronousTaskGraphRunner::~SynchronousTaskGraphRunner() {
16 DCHECK(!work_queue_.HasReadyToRunTasks()); 17 DCHECK(!work_queue_.HasReadyToRunTasks());
17 } 18 }
18 19
19 NamespaceToken SynchronousTaskGraphRunner::GetNamespaceToken() { 20 NamespaceToken SynchronousTaskGraphRunner::GetNamespaceToken() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 58 }
58 59
59 void SynchronousTaskGraphRunner::RunUntilIdle() { 60 void SynchronousTaskGraphRunner::RunUntilIdle() {
60 while (work_queue_.HasReadyToRunTasks()) 61 while (work_queue_.HasReadyToRunTasks())
61 RunTask(); 62 RunTask();
62 } 63 }
63 64
64 void SynchronousTaskGraphRunner::RunTask() { 65 void SynchronousTaskGraphRunner::RunTask() {
65 TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask"); 66 TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask");
66 67
67 auto prioritized_task = work_queue_.GetNextTaskToRun(); 68 // Find the first category with any tasks to run. Categories used by this task
69 // graph runner are ordered by priority.
70 uint16_t category;
71 for (category = 0u; category < kNumTaskCategories; ++category) {
reveman 2015/12/10 16:49:57 I'd like to avoid making the kNumTaskCategories as
ericrk 2015/12/14 19:40:57 What do you think about this approach? It's a bit
72 if (work_queue_.HasReadyToRunTasksForCategory(category))
73 break;
74 }
75 DCHECK(category < kNumTaskCategories);
76
77 auto prioritized_task = work_queue_.GetNextTaskToRun(category);
68 78
69 Task* task = prioritized_task.task; 79 Task* task = prioritized_task.task;
70 task->WillRun(); 80 task->WillRun();
71 task->RunOnWorkerThread(); 81 task->RunOnWorkerThread();
72 task->DidRun(); 82 task->DidRun();
73 83
74 work_queue_.CompleteTask(prioritized_task); 84 work_queue_.CompleteTask(prioritized_task);
75 } 85 }
76 86
77 } // namespace cc 87 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698