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

Unified Diff: cc/raster/task_graph_work_queue.cc

Issue 1903733003: cc: Implement states for Task for stricter control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@land_merge_tile_task_runner
Patch Set: feedback Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/raster/task_graph_runner_perftest.cc ('k') | cc/raster/tile_task.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/raster/task_graph_work_queue.cc
diff --git a/cc/raster/task_graph_work_queue.cc b/cc/raster/task_graph_work_queue.cc
index aa7565473aec4c35e08d9c007db6d9c8c6d38499..807539db8e49252a01c6b346a625525c7d326d85 100644
--- a/cc/raster/task_graph_work_queue.cc
+++ b/cc/raster/task_graph_work_queue.cc
@@ -144,6 +144,11 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) {
});
if (old_it != task_namespace.graph.nodes.end()) {
std::swap(*old_it, task_namespace.graph.nodes.back());
+ // If old task is scheduled to run again and not yet started running,
+ // reset its state to initial state as it has to be inserted in new
+ // |ready_to_run_tasks|, where it gets scheduled.
+ if (node.task->state().IsScheduled())
+ node.task->state().Reset();
task_namespace.graph.nodes.pop_back();
}
@@ -152,7 +157,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) {
continue;
// Skip if already finished running task.
- if (node.task->HasFinishedRunning())
+ if (node.task->state().IsFinished())
continue;
// Skip if already running.
@@ -163,6 +168,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) {
}))
continue;
+ node.task->state().DidSchedule();
task_namespace.ready_to_run_tasks[node.category].push_back(PrioritizedTask(
node.task, &task_namespace, node.category, node.priority));
}
@@ -184,7 +190,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) {
TaskGraph::Node& node = *it;
// Skip if already finished running task.
- if (node.task->HasFinishedRunning())
+ if (node.task->state().IsFinished())
continue;
// Skip if already running.
@@ -198,6 +204,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) {
DCHECK(std::find(task_namespace.completed_tasks.begin(),
task_namespace.completed_tasks.end(),
node.task) == task_namespace.completed_tasks.end());
+ node.task->state().DidCancel();
task_namespace.completed_tasks.push_back(node.task);
}
@@ -258,6 +265,7 @@ TaskGraphWorkQueue::PrioritizedTask TaskGraphWorkQueue::GetNextTaskToRun(
}
// Add task to |running_tasks|.
+ task.task->state().DidStart();
task_namespace->running_tasks.push_back(
std::make_pair(task.category, task.task));
@@ -292,6 +300,7 @@ void TaskGraphWorkQueue::CompleteTask(const PrioritizedTask& completed_task) {
task_namespace->ready_to_run_tasks[dependent_node.category];
bool was_empty = ready_to_run_tasks.empty();
+ dependent_node.task->state().DidSchedule();
ready_to_run_tasks.push_back(
PrioritizedTask(dependent_node.task, task_namespace,
dependent_node.category, dependent_node.priority));
@@ -326,6 +335,7 @@ void TaskGraphWorkQueue::CompleteTask(const PrioritizedTask& completed_task) {
}
// Finally add task to |completed_tasks_|.
+ task->state().DidFinish();
task_namespace->completed_tasks.push_back(task);
}
« no previous file with comments | « cc/raster/task_graph_runner_perftest.cc ('k') | cc/raster/tile_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698