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

Side by Side 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 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/raster/synchronous_task_graph_runner.h"
6
7 #include "base/threading/simple_thread.h"
8 #include "base/threading/thread_restrictions.h"
9 #include "base/trace_event/trace_event.h"
10
11 namespace cc {
12
13 SynchronousTaskGraphRunner::SynchronousTaskGraphRunner() {}
14
15 SynchronousTaskGraphRunner::~SynchronousTaskGraphRunner() {
16 DCHECK(!work_queue_.HasReadyToRunTasks());
17 }
18
19 NamespaceToken SynchronousTaskGraphRunner::GetNamespaceToken() {
20 return work_queue_.GetNamespaceToken();
21 }
22
23 void SynchronousTaskGraphRunner::ScheduleTasks(NamespaceToken token,
24 TaskGraph* graph) {
25 TRACE_EVENT2("cc", "SynchronousTaskGraphRunner::ScheduleTasks", "num_nodes",
26 graph->nodes.size(), "num_edges", graph->edges.size());
27
28 DCHECK(token.IsValid());
29 DCHECK(!TaskGraphWorkQueue::DependencyMismatch(graph));
30
31 work_queue_.ScheduleTasks(token, graph);
32 }
33
34 void SynchronousTaskGraphRunner::WaitForTasksToFinishRunning(
35 NamespaceToken token) {
36 TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::WaitForTasksToFinishRunning");
37
38 DCHECK(token.IsValid());
39 auto* task_namespace = work_queue_.GetNamespaceForToken(token);
40
41 if (!task_namespace)
42 return;
43
44 while (
45 !TaskGraphWorkQueue::HasFinishedRunningTasksInNamespace(task_namespace)) {
46 RunTask();
47 }
48 }
49
50 void SynchronousTaskGraphRunner::CollectCompletedTasks(
51 NamespaceToken token,
52 Task::Vector* completed_tasks) {
53 TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::CollectCompletedTasks");
54
55 DCHECK(token.IsValid());
56 work_queue_.CollectCompletedTasks(token, completed_tasks);
57 }
58
59 void SynchronousTaskGraphRunner::RunUntilIdle() {
60 while (work_queue_.HasReadyToRunTasks())
61 RunTask();
62 }
63
64 void SynchronousTaskGraphRunner::RunTask() {
65 TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask");
66
67 auto prioritized_task = work_queue_.GetNextTaskToRun();
68
69 Task* task = prioritized_task.task;
70 task->WillRun();
71 task->RunOnWorkerThread();
72 task->DidRun();
73
74 work_queue_.CompleteTask(prioritized_task);
75 }
76
77 } // namespace cc
OLDNEW
« 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