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

Side by Side Diff: cc/raster/task_graph_work_queue.h

Issue 1666283002: Reland - Refactor signaling in RWP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid refcounting in schedule Created 4 years, 10 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
« no previous file with comments | « no previous file | cc/raster/task_graph_work_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_ 5 #ifndef CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_
6 #define CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_ 6 #define CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 28 matching lines...) Expand all
39 task_namespace(task_namespace), 39 task_namespace(task_namespace),
40 category(category), 40 category(category),
41 priority(priority) {} 41 priority(priority) {}
42 42
43 Task* task; 43 Task* task;
44 TaskNamespace* task_namespace; 44 TaskNamespace* task_namespace;
45 uint16_t category; 45 uint16_t category;
46 uint16_t priority; 46 uint16_t priority;
47 }; 47 };
48 48
49 using CategorizedTask = std::pair<uint16_t, scoped_refptr<Task>>;
50
49 // Helper classes and static methods used by dependent classes. 51 // Helper classes and static methods used by dependent classes.
50 struct TaskNamespace { 52 struct TaskNamespace {
51 typedef std::vector<TaskNamespace*> Vector; 53 typedef std::vector<TaskNamespace*> Vector;
52 54
53 TaskNamespace(); 55 TaskNamespace();
54 ~TaskNamespace(); 56 ~TaskNamespace();
55 57
56 // Current task graph. 58 // Current task graph.
57 TaskGraph graph; 59 TaskGraph graph;
58 60
59 // Map from category to a vector of tasks that are ready to run for that 61 // Map from category to a vector of tasks that are ready to run for that
60 // category. 62 // category.
61 std::map<uint16_t, PrioritizedTask::Vector> ready_to_run_tasks; 63 std::map<uint16_t, PrioritizedTask::Vector> ready_to_run_tasks;
62 64
63 // Completed tasks not yet collected by origin thread. 65 // Completed tasks not yet collected by origin thread.
64 Task::Vector completed_tasks; 66 Task::Vector completed_tasks;
65 67
66 // This set contains all currently running tasks. 68 // This set contains all currently running tasks.
67 Task::Vector running_tasks; 69 std::vector<CategorizedTask> running_tasks;
68 }; 70 };
69 71
70 TaskGraphWorkQueue(); 72 TaskGraphWorkQueue();
71 virtual ~TaskGraphWorkQueue(); 73 virtual ~TaskGraphWorkQueue();
72 74
73 // Gets a NamespaceToken which is guaranteed to be unique within this 75 // Gets a NamespaceToken which is guaranteed to be unique within this
74 // TaskGraphWorkQueue. 76 // TaskGraphWorkQueue.
75 NamespaceToken GetNamespaceToken(); 77 NamespaceToken GetNamespaceToken();
76 78
77 // Updates a TaskNamespace with a new TaskGraph to run. This cancels any 79 // Updates a TaskNamespace with a new TaskGraph to run. This cancels any
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 [](const TaskNamespaceMap::value_type& entry) { 140 [](const TaskNamespaceMap::value_type& entry) {
139 return !HasFinishedRunningTasksInNamespace(&entry.second); 141 return !HasFinishedRunningTasksInNamespace(&entry.second);
140 }) == namespaces_.end(); 142 }) == namespaces_.end();
141 } 143 }
142 144
143 const std::map<uint16_t, TaskNamespace::Vector>& ready_to_run_namespaces() 145 const std::map<uint16_t, TaskNamespace::Vector>& ready_to_run_namespaces()
144 const { 146 const {
145 return ready_to_run_namespaces_; 147 return ready_to_run_namespaces_;
146 } 148 }
147 149
150 size_t NumRunningTasksForCategory(uint16_t category) const {
151 size_t count = 0;
152 for (const auto& task_namespace_entry : namespaces_) {
153 for (const auto& categorized_task :
154 task_namespace_entry.second.running_tasks) {
155 if (categorized_task.first == category) {
156 count++;
reveman 2016/02/24 19:34:29 nit: ++count is typically preferred in chromium co
ericrk 2016/02/24 19:49:27 k
157 }
158 }
159 }
160 return count;
161 }
162
148 // Helper function which ensures that graph dependencies were correctly 163 // Helper function which ensures that graph dependencies were correctly
149 // configured. 164 // configured.
150 static bool DependencyMismatch(const TaskGraph* graph); 165 static bool DependencyMismatch(const TaskGraph* graph);
151 166
152 private: 167 private:
153 // Helper class used to provide NamespaceToken comparison to TaskNamespaceMap. 168 // Helper class used to provide NamespaceToken comparison to TaskNamespaceMap.
154 class CompareToken { 169 class CompareToken {
155 public: 170 public:
156 bool operator()(const NamespaceToken& lhs, 171 bool operator()(const NamespaceToken& lhs,
157 const NamespaceToken& rhs) const { 172 const NamespaceToken& rhs) const {
158 return lhs.id_ < rhs.id_; 173 return lhs.id_ < rhs.id_;
159 } 174 }
160 }; 175 };
161 176
162 using TaskNamespaceMap = 177 using TaskNamespaceMap =
163 std::map<NamespaceToken, TaskNamespace, CompareToken>; 178 std::map<NamespaceToken, TaskNamespace, CompareToken>;
164 179
165 TaskNamespaceMap namespaces_; 180 TaskNamespaceMap namespaces_;
166 181
167 // Map from category to a vector of ready to run namespaces for that category. 182 // Map from category to a vector of ready to run namespaces for that category.
168 std::map<uint16_t, TaskNamespace::Vector> ready_to_run_namespaces_; 183 std::map<uint16_t, TaskNamespace::Vector> ready_to_run_namespaces_;
169 184
170 // Provides a unique id to each NamespaceToken. 185 // Provides a unique id to each NamespaceToken.
171 int next_namespace_id_; 186 int next_namespace_id_;
172 }; 187 };
173 188
174 } // namespace cc 189 } // namespace cc
175 190
176 #endif // CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_ 191 #endif // CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_
OLDNEW
« no previous file with comments | « no previous file | cc/raster/task_graph_work_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698