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

Unified Diff: cc/raster/task_graph_work_queue.h

Issue 1489233003: TaskGraphRunner Group support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor
Patch Set: rebase Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: cc/raster/task_graph_work_queue.h
diff --git a/cc/raster/task_graph_work_queue.h b/cc/raster/task_graph_work_queue.h
index 8a461232cbfbc536016a620317bef4e6f235ebb8..2200ecd6f709befc6ae2ce4803b0dd7f3848ea99 100644
--- a/cc/raster/task_graph_work_queue.h
+++ b/cc/raster/task_graph_work_queue.h
@@ -16,19 +16,34 @@ namespace cc {
// Implements a queue of incoming TaskGraph work. Designed for use by
// implementations of TaskGraphRunner. Not thread safe, so the caller is
// responsible for all necessary locking.
+//
+// Tasks in the queue are divided into groups. Tasks from a single graph may
+// be put into different groups, each of which is prioritized independently
+// from the others. It is up to the implementation of TaskGraphRunner to
+// define the meaning of the groups and handle them appropriately.
class CC_EXPORT TaskGraphWorkQueue {
public:
+ // This value is chosen as the max needed at the moment.
+ enum : uint16_t { kMaxTaskGroups = 3 };
reveman 2015/12/04 02:30:54 hm, not a huge fan of this. if this is going to be
ericrk 2015/12/04 19:14:31 ok - heh... I have that code 2 or 3 CLs back in th
+
struct TaskNamespace;
struct PrioritizedTask {
typedef std::vector<PrioritizedTask> Vector;
- PrioritizedTask(Task* task, TaskNamespace* task_namespace, size_t priority)
- : task(task), task_namespace(task_namespace), priority(priority) {}
+ PrioritizedTask(Task* task,
+ TaskNamespace* task_namespace,
+ uint16_t group,
+ uint16_t priority)
+ : task(task),
+ task_namespace(task_namespace),
+ group(group),
+ priority(priority) {}
Task* task;
TaskNamespace* task_namespace;
- size_t priority;
+ uint16_t group;
+ uint16_t priority;
};
// Helper classes and static methods used by dependent classes.
@@ -41,8 +56,8 @@ class CC_EXPORT TaskGraphWorkQueue {
// Current task graph.
TaskGraph graph;
- // Ordered set of tasks that are ready to run.
- PrioritizedTask::Vector ready_to_run_tasks;
+ // One ordered set of tasks that are ready to run for each group.
+ PrioritizedTask::Vector ready_to_run_tasks[kMaxTaskGroups];
// Completed tasks not yet collected by origin thread.
Task::Vector completed_tasks;
@@ -62,9 +77,13 @@ class CC_EXPORT TaskGraphWorkQueue {
// previous tasks in the graph being replaced.
void ScheduleTasks(NamespaceToken token, TaskGraph* graph);
- // Returns the next task to run paired with its namespace.
+ // Returns the next task to run. Treats group as a secondary priority (group
+ // 0 runs before group 1).
PrioritizedTask GetNextTaskToRun();
reveman 2015/12/04 02:30:54 Is this the only code in TaskGraphWorkQueue that t
ericrk 2015/12/04 19:14:31 sgtm
+ // Returns the next task to run for the given group.
+ PrioritizedTask GetNextTaskToRunForGroup(uint16_t group);
+
// Marks a task as completed, adding it to its namespace's list of completed
// tasks and updating the list of |ready_to_run_namespaces|.
void CompleteTask(const PrioritizedTask& completed_task);
@@ -85,12 +104,14 @@ class CC_EXPORT TaskGraphWorkQueue {
}
static bool HasFinishedRunningTasksInNamespace(
- const TaskNamespace* task_namespace) {
- return task_namespace->running_tasks.empty() &&
- task_namespace->ready_to_run_tasks.empty();
- }
+ const TaskNamespace* task_namespace);
- bool HasReadyToRunTasks() const { return !ready_to_run_namespaces_.empty(); }
+ bool HasReadyToRunTasks() const;
+
+ bool HasReadyToRunTasksForGroup(uint16_t group) const {
+ DCHECK(group < kMaxTaskGroups);
+ return ready_to_run_namespaces_[group].empty();
+ }
bool HasAnyNamespaces() const { return !namespaces_.empty(); }
@@ -116,29 +137,16 @@ class CC_EXPORT TaskGraphWorkQueue {
}
};
- static bool CompareTaskPriority(const PrioritizedTask& a,
- const PrioritizedTask& b) {
- // In this system, numerically lower priority is run first.
- return a.priority > b.priority;
- }
-
- static bool CompareTaskNamespacePriority(const TaskNamespace* a,
- const TaskNamespace* b) {
- DCHECK(!a->ready_to_run_tasks.empty());
- DCHECK(!b->ready_to_run_tasks.empty());
-
- // Compare based on task priority of the ready_to_run_tasks heap .front()
- // will hold the max element of the heap, except after pop_heap, when max
- // element is moved to .back().
- return CompareTaskPriority(a->ready_to_run_tasks.front(),
- b->ready_to_run_tasks.front());
- }
+ // Validates that no group in a graph exceeds |kMaxTaskGroups|.
+ static bool ValidateGroups(const TaskGraph* graph);
using TaskNamespaceMap =
std::map<NamespaceToken, TaskNamespace, CompareToken>;
TaskNamespaceMap namespaces_;
- TaskNamespace::Vector ready_to_run_namespaces_;
+
+ // A vector of ready to run namespaces for each group.
+ TaskNamespace::Vector ready_to_run_namespaces_[kMaxTaskGroups];
// Provides a unique id to each NamespaceToken.
int next_namespace_id_;

Powered by Google App Engine
This is Rietveld 408576698