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

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: 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 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 void SynchronousTaskGraphRunner::ScheduleTasks(NamespaceToken token,
20 TaskGraph* graph) {
21 TRACE_EVENT2("cc", "SynchronousTaskGraphRunner::ScheduleTasks", "num_nodes",
22 graph->nodes.size(), "num_edges", graph->edges.size());
23
24 DCHECK(token.IsValid());
25 DCHECK(!DependencyMismatch(graph));
26
27 work_queue_.ScheduleTasks(token, graph);
28 }
29
30 void SynchronousTaskGraphRunner::WaitForTasksToFinishRunning(
31 NamespaceToken token) {
32 TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::WaitForTasksToFinishRunning");
33
34 DCHECK(token.IsValid());
35 auto* task_namespace = work_queue_.GetNamespaceForToken(token);
36
37 if (!task_namespace)
38 return;
39
40 while (
41 !TaskGraphWorkQueue::HasFinishedRunningTasksInNamespace(task_namespace))
reveman 2015/11/19 16:05:46 heh, cl format is not always making the best choic
ericrk 2015/11/23 18:43:37 yup... heh
42 RunTask();
43 }
44
45 void SynchronousTaskGraphRunner::CollectCompletedTasks(
46 NamespaceToken token,
47 Task::Vector* completed_tasks) {
48 TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::CollectCompletedTasks");
49
50 DCHECK(token.IsValid());
51 work_queue_.CollectCompletedTasks(token, completed_tasks);
52 }
53
54 void SynchronousTaskGraphRunner::RunUntilIdle() {
55 while (work_queue_.HasReadyToRunTasks())
56 RunTask();
57 }
58
59 void SynchronousTaskGraphRunner::RunTask() {
60 TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask");
61
62 auto prioritized_task = work_queue_.GetNextTaskToRun();
63
64 Task* task = prioritized_task.task;
65 task->WillRun();
66 task->RunOnWorkerThread();
67 task->DidRun();
68
69 work_queue_.CompleteTask(prioritized_task);
70 }
71
72 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698