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 "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" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 void SingleThreadTaskGraphRunner::ScheduleTasks(NamespaceToken token, | 52 void SingleThreadTaskGraphRunner::ScheduleTasks(NamespaceToken token, |
53 TaskGraph* graph) { | 53 TaskGraph* graph) { |
54 TRACE_EVENT2("cc", "SingleThreadTaskGraphRunner::ScheduleTasks", "num_nodes", | 54 TRACE_EVENT2("cc", "SingleThreadTaskGraphRunner::ScheduleTasks", "num_nodes", |
55 graph->nodes.size(), "num_edges", graph->edges.size()); | 55 graph->nodes.size(), "num_edges", graph->edges.size()); |
56 | 56 |
57 DCHECK(token.IsValid()); | 57 DCHECK(token.IsValid()); |
58 DCHECK(!TaskGraphWorkQueue::DependencyMismatch(graph)); | 58 DCHECK(!TaskGraphWorkQueue::DependencyMismatch(graph)); |
59 | 59 |
| 60 // SingleThreadTaskGraphRunner does not care about categories. |
| 61 TaskGraphWorkQueue::UncategorizeTaskGraph(graph); |
| 62 |
60 { | 63 { |
61 base::AutoLock lock(lock_); | 64 base::AutoLock lock(lock_); |
62 | 65 |
63 DCHECK(!shutdown_); | 66 DCHECK(!shutdown_); |
64 | 67 |
65 work_queue_.ScheduleTasks(token, graph); | 68 work_queue_.ScheduleTasks(token, graph); |
66 | 69 |
67 // If there is more work available, wake up the worker thread. | 70 // If there is more work available, wake up the worker thread. |
68 if (work_queue_.HasReadyToRunTasks()) | 71 if (work_queue_.HasReadyToRunTasks()) |
69 has_ready_to_run_tasks_cv_.Signal(); | 72 has_ready_to_run_tasks_cv_.Signal(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 RunTaskWithLockAcquired(); | 128 RunTaskWithLockAcquired(); |
126 } | 129 } |
127 } | 130 } |
128 | 131 |
129 void SingleThreadTaskGraphRunner::RunTaskWithLockAcquired() { | 132 void SingleThreadTaskGraphRunner::RunTaskWithLockAcquired() { |
130 TRACE_EVENT0("toplevel", | 133 TRACE_EVENT0("toplevel", |
131 "SingleThreadTaskGraphRunner::RunTaskWithLockAcquired"); | 134 "SingleThreadTaskGraphRunner::RunTaskWithLockAcquired"); |
132 | 135 |
133 lock_.AssertAcquired(); | 136 lock_.AssertAcquired(); |
134 | 137 |
135 auto prioritized_task = work_queue_.GetNextTaskToRun(); | 138 auto prioritized_task = work_queue_.GetNextTaskToRun(0u /* category */); |
136 Task* task = prioritized_task.task; | 139 Task* task = prioritized_task.task; |
137 | 140 |
138 // Call WillRun() before releasing |lock_| and running task. | 141 // Call WillRun() before releasing |lock_| and running task. |
139 task->WillRun(); | 142 task->WillRun(); |
140 | 143 |
141 { | 144 { |
142 base::AutoUnlock unlock(lock_); | 145 base::AutoUnlock unlock(lock_); |
143 task->RunOnWorkerThread(); | 146 task->RunOnWorkerThread(); |
144 } | 147 } |
145 | 148 |
146 // This will mark task as finished running. | 149 // This will mark task as finished running. |
147 task->DidRun(); | 150 task->DidRun(); |
148 | 151 |
149 work_queue_.CompleteTask(prioritized_task); | 152 work_queue_.CompleteTask(prioritized_task); |
150 | 153 |
151 // If namespace has finished running all tasks, wake up origin thread. | 154 // If namespace has finished running all tasks, wake up origin thread. |
152 if (work_queue_.HasFinishedRunningTasksInNamespace( | 155 if (work_queue_.HasFinishedRunningTasksInNamespace( |
153 prioritized_task.task_namespace)) | 156 prioritized_task.task_namespace)) |
154 has_namespaces_with_finished_running_tasks_cv_.Signal(); | 157 has_namespaces_with_finished_running_tasks_cv_.Signal(); |
155 } | 158 } |
156 | 159 |
157 } // namespace cc | 160 } // namespace cc |
OLD | NEW |