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

Unified Diff: cc/raster/synchronous_task_graph_runner.cc

Issue 1489233003: TaskGraphRunner Group support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor
Patch Set: 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
« no previous file with comments | « cc/raster/synchronous_task_graph_runner.h ('k') | cc/raster/task_graph_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/raster/synchronous_task_graph_runner.cc
diff --git a/cc/raster/synchronous_task_graph_runner.cc b/cc/raster/synchronous_task_graph_runner.cc
index ed05cfb5823127277020491b4b5fbb0d6e3abbd2..156ef9acda846f0d2ef840ecee922d2aa3e69869 100644
--- a/cc/raster/synchronous_task_graph_runner.cc
+++ b/cc/raster/synchronous_task_graph_runner.cc
@@ -4,6 +4,9 @@
#include "cc/raster/synchronous_task_graph_runner.h"
+#include <algorithm>
+#include <utility>
+
#include "base/threading/simple_thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/trace_event/trace_event.h"
@@ -41,9 +44,9 @@ void SynchronousTaskGraphRunner::WaitForTasksToFinishRunning(
if (!task_namespace)
return;
- while (
- !TaskGraphWorkQueue::HasFinishedRunningTasksInNamespace(task_namespace)) {
- RunTask();
+ while (!work_queue_.HasFinishedRunningTasksInNamespace(task_namespace)) {
+ bool succeeded = RunTask();
+ DCHECK(succeeded);
}
}
@@ -57,14 +60,27 @@ void SynchronousTaskGraphRunner::CollectCompletedTasks(
}
void SynchronousTaskGraphRunner::RunUntilIdle() {
- while (work_queue_.HasReadyToRunTasks())
- RunTask();
+ while (RunTask()) {
+ }
}
-void SynchronousTaskGraphRunner::RunTask() {
+bool SynchronousTaskGraphRunner::RunTask() {
TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask");
- auto prioritized_task = work_queue_.GetNextTaskToRun();
+ // Find the first category with any tasks to run. This task graph runner
+ // treats categories as an additional priority.
+ const auto& ready_to_run_namespaces = work_queue_.ready_to_run_namespaces();
+ auto found = std::find_if(
+ ready_to_run_namespaces.cbegin(), ready_to_run_namespaces.cend(),
+ [](const std::pair<uint16_t, TaskGraphWorkQueue::TaskNamespace::Vector>&
+ pair) { return !pair.second.empty(); });
+
+ if (found == ready_to_run_namespaces.cend()) {
+ return false;
+ }
+
+ const uint16_t category = found->first;
+ auto prioritized_task = work_queue_.GetNextTaskToRun(category);
Task* task = prioritized_task.task;
task->WillRun();
@@ -72,6 +88,8 @@ void SynchronousTaskGraphRunner::RunTask() {
task->DidRun();
work_queue_.CompleteTask(prioritized_task);
+
+ return true;
}
} // namespace cc
« no previous file with comments | « cc/raster/synchronous_task_graph_runner.h ('k') | cc/raster/task_graph_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698