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 #include "cc/resources/task_graph_runner.h" | 5 #include "cc/resources/task_graph_runner.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 75 |
76 const std::vector<unsigned>& on_task_completed_ids(int namespace_index) { | 76 const std::vector<unsigned>& on_task_completed_ids(int namespace_index) { |
77 return on_task_completed_ids_[namespace_index]; | 77 return on_task_completed_ids_[namespace_index]; |
78 } | 78 } |
79 | 79 |
80 void ScheduleTasks(int namespace_index, const std::vector<TaskInfo>& tasks) { | 80 void ScheduleTasks(int namespace_index, const std::vector<TaskInfo>& tasks) { |
81 Task::Vector new_tasks; | 81 Task::Vector new_tasks; |
82 Task::Vector new_dependents; | 82 Task::Vector new_dependents; |
83 TaskGraph new_graph; | 83 TaskGraph new_graph; |
84 | 84 |
85 int sub_namespace = 0; | |
86 int max_concurrent_tasks = 4; | |
danakj
2015/02/23 18:45:01
no tests with different values to verify this work
| |
87 | |
85 for (std::vector<TaskInfo>::const_iterator it = tasks.begin(); | 88 for (std::vector<TaskInfo>::const_iterator it = tasks.begin(); |
86 it != tasks.end(); | 89 it != tasks.end(); |
87 ++it) { | 90 ++it) { |
88 scoped_refptr<FakeTaskImpl> new_task( | 91 scoped_refptr<FakeTaskImpl> new_task( |
89 new FakeTaskImpl(this, it->namespace_index, it->id)); | 92 new FakeTaskImpl(this, it->namespace_index, it->id)); |
90 new_graph.nodes.push_back( | 93 new_graph.nodes.push_back(TaskGraph::Node(new_task.get(), it->priority, |
91 TaskGraph::Node(new_task.get(), it->priority, 0u)); | 94 0u, sub_namespace, |
95 max_concurrent_tasks)); | |
92 for (unsigned i = 0; i < it->dependent_count; ++i) { | 96 for (unsigned i = 0; i < it->dependent_count; ++i) { |
93 scoped_refptr<FakeDependentTaskImpl> new_dependent_task( | 97 scoped_refptr<FakeDependentTaskImpl> new_dependent_task( |
94 new FakeDependentTaskImpl( | 98 new FakeDependentTaskImpl( |
95 this, it->namespace_index, it->dependent_id)); | 99 this, it->namespace_index, it->dependent_id)); |
96 new_graph.nodes.push_back( | 100 new_graph.nodes.push_back( |
97 TaskGraph::Node(new_dependent_task.get(), it->priority, 1u)); | 101 TaskGraph::Node(new_dependent_task.get(), it->priority, 1u, |
102 sub_namespace, max_concurrent_tasks)); | |
98 new_graph.edges.push_back( | 103 new_graph.edges.push_back( |
99 TaskGraph::Edge(new_task.get(), new_dependent_task.get())); | 104 TaskGraph::Edge(new_task.get(), new_dependent_task.get())); |
100 | 105 |
101 new_dependents.push_back(new_dependent_task.get()); | 106 new_dependents.push_back(new_dependent_task.get()); |
102 } | 107 } |
103 | 108 |
104 new_tasks.push_back(new_task.get()); | 109 new_tasks.push_back(new_task.get()); |
105 } | 110 } |
106 | 111 |
107 task_graph_runner_->ScheduleTasks(namespace_token_[namespace_index], | 112 task_graph_runner_->ScheduleTasks(namespace_token_[namespace_index], |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 EXPECT_EQ(0u, run_task_ids(i)[2]); | 327 EXPECT_EQ(0u, run_task_ids(i)[2]); |
323 EXPECT_EQ(2u, run_task_ids(i)[3]); | 328 EXPECT_EQ(2u, run_task_ids(i)[3]); |
324 ASSERT_EQ(2u, on_task_completed_ids(i).size()); | 329 ASSERT_EQ(2u, on_task_completed_ids(i).size()); |
325 EXPECT_EQ(1u, on_task_completed_ids(i)[0]); | 330 EXPECT_EQ(1u, on_task_completed_ids(i)[0]); |
326 EXPECT_EQ(0u, on_task_completed_ids(i)[1]); | 331 EXPECT_EQ(0u, on_task_completed_ids(i)[1]); |
327 } | 332 } |
328 } | 333 } |
329 | 334 |
330 } // namespace | 335 } // namespace |
331 } // namespace cc | 336 } // namespace cc |
OLD | NEW |