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_RUNNER_H_ | 5 #ifndef CC_RASTER_TASK_GRAPH_RUNNER_H_ |
6 #define CC_RASTER_TASK_GRAPH_RUNNER_H_ | 6 #define CC_RASTER_TASK_GRAPH_RUNNER_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 Task(); | 40 Task(); |
41 virtual ~Task(); | 41 virtual ~Task(); |
42 | 42 |
43 bool will_run_; | 43 bool will_run_; |
44 bool did_run_; | 44 bool did_run_; |
45 }; | 45 }; |
46 | 46 |
47 // A task dependency graph describes the order in which to execute a set | 47 // A task dependency graph describes the order in which to execute a set |
48 // of tasks. Dependencies are represented as edges. Each node is assigned | 48 // of tasks. Dependencies are represented as edges. Each node is assigned |
49 // a priority and a run count that matches the number of dependencies. | 49 // a category, a priority and a run count that matches the number of |
50 // Priority range from 0 (most favorable scheduling) to UINT_MAX | 50 // dependencies. Priority range from 0 (most favorable scheduling) to UINT16_MAX |
51 // (least favorable). | 51 // (least favorable). Categories range from 0 to UINT16_MAX. It is up to the |
| 52 // implementation and its consumer to determine the meaning (if any) of a |
| 53 // category. A TaskGraphRunner implementation may chose to prioritize certain |
| 54 // categories over others, regardless of the individual priorities of tasks. |
52 struct CC_EXPORT TaskGraph { | 55 struct CC_EXPORT TaskGraph { |
53 struct Node { | 56 struct Node { |
54 typedef std::vector<Node> Vector; | 57 typedef std::vector<Node> Vector; |
55 | 58 |
56 Node(Task* task, size_t priority, size_t dependencies) | 59 Node(Task* task, |
57 : task(task), priority(priority), dependencies(dependencies) {} | 60 uint16_t category, |
| 61 uint16_t priority, |
| 62 uint32_t dependencies) |
| 63 : task(task), |
| 64 category(category), |
| 65 priority(priority), |
| 66 dependencies(dependencies) {} |
58 | 67 |
59 Task* task; | 68 Task* task; |
60 size_t priority; | 69 uint16_t category; |
61 size_t dependencies; | 70 uint16_t priority; |
| 71 uint32_t dependencies; |
62 }; | 72 }; |
63 | 73 |
64 struct Edge { | 74 struct Edge { |
65 typedef std::vector<Edge> Vector; | 75 typedef std::vector<Edge> Vector; |
66 | 76 |
67 Edge(const Task* task, Task* dependent) | 77 Edge(const Task* task, Task* dependent) |
68 : task(task), dependent(dependent) {} | 78 : task(task), dependent(dependent) {} |
69 | 79 |
70 const Task* task; | 80 const Task* task; |
71 Task* dependent; | 81 Task* dependent; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 private: | 213 private: |
204 TaskGraph* graph_; | 214 TaskGraph* graph_; |
205 const Task* task_; | 215 const Task* task_; |
206 size_t current_index_; | 216 size_t current_index_; |
207 TaskGraph::Node* current_node_; | 217 TaskGraph::Node* current_node_; |
208 }; | 218 }; |
209 | 219 |
210 } // namespace cc | 220 } // namespace cc |
211 | 221 |
212 #endif // CC_RASTER_TASK_GRAPH_RUNNER_H_ | 222 #endif // CC_RASTER_TASK_GRAPH_RUNNER_H_ |
OLD | NEW |