Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 [](const TaskNamespaceMap::value_type& entry) { | 138 [](const TaskNamespaceMap::value_type& entry) { |
| 139 return !HasFinishedRunningTasksInNamespace(&entry.second); | 139 return !HasFinishedRunningTasksInNamespace(&entry.second); |
| 140 }) == namespaces_.end(); | 140 }) == namespaces_.end(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 const std::map<uint16_t, TaskNamespace::Vector>& ready_to_run_namespaces() | 143 const std::map<uint16_t, TaskNamespace::Vector>& ready_to_run_namespaces() |
| 144 const { | 144 const { |
| 145 return ready_to_run_namespaces_; | 145 return ready_to_run_namespaces_; |
| 146 } | 146 } |
| 147 | 147 |
| 148 uint32_t NumRunningTasks() const { | |
|
reveman
2016/02/08 19:10:21
Do we need both of these functions or is the one b
ericrk
2016/02/10 18:44:49
Not really - we can drop this one for now.
| |
| 149 uint32_t count = 0; | |
| 150 for (const auto& running_task_count_entry : running_task_count_) { | |
| 151 count += running_task_count_entry.second; | |
| 152 } | |
| 153 return count; | |
| 154 } | |
| 155 | |
| 156 uint32_t NumRunningTasksForCategory(uint16_t category) const { | |
| 157 auto found = running_task_count_.find(category); | |
| 158 if (found != running_task_count_.end()) { | |
| 159 return found->second; | |
| 160 } | |
| 161 return 0; | |
| 162 } | |
| 163 | |
| 148 // Helper function which ensures that graph dependencies were correctly | 164 // Helper function which ensures that graph dependencies were correctly |
| 149 // configured. | 165 // configured. |
| 150 static bool DependencyMismatch(const TaskGraph* graph); | 166 static bool DependencyMismatch(const TaskGraph* graph); |
| 151 | 167 |
| 152 private: | 168 private: |
| 153 // Helper class used to provide NamespaceToken comparison to TaskNamespaceMap. | 169 // Helper class used to provide NamespaceToken comparison to TaskNamespaceMap. |
| 154 class CompareToken { | 170 class CompareToken { |
| 155 public: | 171 public: |
| 156 bool operator()(const NamespaceToken& lhs, | 172 bool operator()(const NamespaceToken& lhs, |
| 157 const NamespaceToken& rhs) const { | 173 const NamespaceToken& rhs) const { |
| 158 return lhs.id_ < rhs.id_; | 174 return lhs.id_ < rhs.id_; |
| 159 } | 175 } |
| 160 }; | 176 }; |
| 161 | 177 |
| 162 using TaskNamespaceMap = | 178 using TaskNamespaceMap = |
| 163 std::map<NamespaceToken, TaskNamespace, CompareToken>; | 179 std::map<NamespaceToken, TaskNamespace, CompareToken>; |
| 164 | 180 |
| 165 TaskNamespaceMap namespaces_; | 181 TaskNamespaceMap namespaces_; |
| 166 | 182 |
| 167 // Map from category to a vector of ready to run namespaces for that category. | 183 // 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_; | 184 std::map<uint16_t, TaskNamespace::Vector> ready_to_run_namespaces_; |
| 169 | 185 |
| 186 // Helper variable tracking the number of running tasks in each category. We | |
| 187 // could calculate this from data in namespaces_, but it would be less | |
| 188 // efficient. | |
| 189 std::map<uint16_t, uint32_t> running_task_count_; | |
|
reveman
2016/02/08 19:10:21
I'd prefer if we minimized state and looped over a
ericrk
2016/02/10 18:44:49
Sure, went back and forth on this - can make this
| |
| 190 | |
| 170 // Provides a unique id to each NamespaceToken. | 191 // Provides a unique id to each NamespaceToken. |
| 171 int next_namespace_id_; | 192 int next_namespace_id_; |
| 172 }; | 193 }; |
| 173 | 194 |
| 174 } // namespace cc | 195 } // namespace cc |
| 175 | 196 |
| 176 #endif // CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_ | 197 #endif // CC_RASTER_TASK_GRAPH_WORK_QUEUE_H_ |
| OLD | NEW |