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

Side by Side Diff: cc/raster/single_thread_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/single_thread_task_graph_runner.h" 5 #include "cc/raster/single_thread_task_graph_runner.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/threading/simple_thread.h" 9 #include "base/threading/simple_thread.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "cc/raster/task_category.h"
12 13
13 namespace cc { 14 namespace cc {
14 15
15 SingleThreadTaskGraphRunner::SingleThreadTaskGraphRunner() 16 SingleThreadTaskGraphRunner::SingleThreadTaskGraphRunner()
16 : lock_(), 17 : lock_(),
17 has_ready_to_run_tasks_cv_(&lock_), 18 has_ready_to_run_tasks_cv_(&lock_),
18 has_namespaces_with_finished_running_tasks_cv_(&lock_), 19 has_namespaces_with_finished_running_tasks_cv_(&lock_),
19 shutdown_(false) {} 20 shutdown_(false) {}
20 21
21 SingleThreadTaskGraphRunner::~SingleThreadTaskGraphRunner() {} 22 SingleThreadTaskGraphRunner::~SingleThreadTaskGraphRunner() {}
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 RunTaskWithLockAcquired(); 126 RunTaskWithLockAcquired();
126 } 127 }
127 } 128 }
128 129
129 void SingleThreadTaskGraphRunner::RunTaskWithLockAcquired() { 130 void SingleThreadTaskGraphRunner::RunTaskWithLockAcquired() {
130 TRACE_EVENT0("toplevel", 131 TRACE_EVENT0("toplevel",
131 "SingleThreadTaskGraphRunner::RunTaskWithLockAcquired"); 132 "SingleThreadTaskGraphRunner::RunTaskWithLockAcquired");
132 133
133 lock_.AssertAcquired(); 134 lock_.AssertAcquired();
134 135
135 auto prioritized_task = work_queue_.GetNextTaskToRun(); 136 // Find the first category with any tasks to run. Categories used by this task
137 // graph runner are ordered by priority.
138 uint16_t category;
139 for (category = 0u; category < kNumTaskCategories; ++category) {
140 if (work_queue_.HasReadyToRunTasksForCategory(category))
141 break;
142 }
143 DCHECK(category < kNumTaskCategories);
144
145 auto prioritized_task = work_queue_.GetNextTaskToRun(category);
136 Task* task = prioritized_task.task; 146 Task* task = prioritized_task.task;
137 147
138 // Call WillRun() before releasing |lock_| and running task. 148 // Call WillRun() before releasing |lock_| and running task.
139 task->WillRun(); 149 task->WillRun();
140 150
141 { 151 {
142 base::AutoUnlock unlock(lock_); 152 base::AutoUnlock unlock(lock_);
143 task->RunOnWorkerThread(); 153 task->RunOnWorkerThread();
144 } 154 }
145 155
146 // This will mark task as finished running. 156 // This will mark task as finished running.
147 task->DidRun(); 157 task->DidRun();
148 158
149 work_queue_.CompleteTask(prioritized_task); 159 work_queue_.CompleteTask(prioritized_task);
150 160
151 // If namespace has finished running all tasks, wake up origin thread. 161 // If namespace has finished running all tasks, wake up origin thread.
152 if (work_queue_.HasFinishedRunningTasksInNamespace( 162 if (work_queue_.HasFinishedRunningTasksInNamespace(
153 prioritized_task.task_namespace)) 163 prioritized_task.task_namespace))
154 has_namespaces_with_finished_running_tasks_cv_.Signal(); 164 has_namespaces_with_finished_running_tasks_cv_.Signal();
155 } 165 }
156 166
157 } // namespace cc 167 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698