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

Unified Diff: cc/raster/synchronous_task_graph_runner.cc

Issue 1449133002: TaskGraphRunner refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 5 years, 1 month 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/synchronous_task_graph_runner_unittest.cc » ('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
new file mode 100644
index 0000000000000000000000000000000000000000..ed05cfb5823127277020491b4b5fbb0d6e3abbd2
--- /dev/null
+++ b/cc/raster/synchronous_task_graph_runner.cc
@@ -0,0 +1,77 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/raster/synchronous_task_graph_runner.h"
+
+#include "base/threading/simple_thread.h"
+#include "base/threading/thread_restrictions.h"
+#include "base/trace_event/trace_event.h"
+
+namespace cc {
+
+SynchronousTaskGraphRunner::SynchronousTaskGraphRunner() {}
+
+SynchronousTaskGraphRunner::~SynchronousTaskGraphRunner() {
+ DCHECK(!work_queue_.HasReadyToRunTasks());
+}
+
+NamespaceToken SynchronousTaskGraphRunner::GetNamespaceToken() {
+ return work_queue_.GetNamespaceToken();
+}
+
+void SynchronousTaskGraphRunner::ScheduleTasks(NamespaceToken token,
+ TaskGraph* graph) {
+ TRACE_EVENT2("cc", "SynchronousTaskGraphRunner::ScheduleTasks", "num_nodes",
+ graph->nodes.size(), "num_edges", graph->edges.size());
+
+ DCHECK(token.IsValid());
+ DCHECK(!TaskGraphWorkQueue::DependencyMismatch(graph));
+
+ work_queue_.ScheduleTasks(token, graph);
+}
+
+void SynchronousTaskGraphRunner::WaitForTasksToFinishRunning(
+ NamespaceToken token) {
+ TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::WaitForTasksToFinishRunning");
+
+ DCHECK(token.IsValid());
+ auto* task_namespace = work_queue_.GetNamespaceForToken(token);
+
+ if (!task_namespace)
+ return;
+
+ while (
+ !TaskGraphWorkQueue::HasFinishedRunningTasksInNamespace(task_namespace)) {
+ RunTask();
+ }
+}
+
+void SynchronousTaskGraphRunner::CollectCompletedTasks(
+ NamespaceToken token,
+ Task::Vector* completed_tasks) {
+ TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::CollectCompletedTasks");
+
+ DCHECK(token.IsValid());
+ work_queue_.CollectCompletedTasks(token, completed_tasks);
+}
+
+void SynchronousTaskGraphRunner::RunUntilIdle() {
+ while (work_queue_.HasReadyToRunTasks())
+ RunTask();
+}
+
+void SynchronousTaskGraphRunner::RunTask() {
+ TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask");
+
+ auto prioritized_task = work_queue_.GetNextTaskToRun();
+
+ Task* task = prioritized_task.task;
+ task->WillRun();
+ task->RunOnWorkerThread();
+ task->DidRun();
+
+ work_queue_.CompleteTask(prioritized_task);
+}
+
+} // namespace cc
« no previous file with comments | « cc/raster/synchronous_task_graph_runner.h ('k') | cc/raster/synchronous_task_graph_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698