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

Side by Side Diff: cc/raster/single_thread_task_graph_runner.h

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 #ifndef CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_
6 #define CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/simple_thread.h"
10 #include "cc/raster/task_graph_runner.h"
11 #include "cc/raster/task_graph_work_queue.h"
12
13 namespace base {
14 class SimpleThread;
15 }
16
17 namespace cc {
18
19 // Runs TaskGraphs asynchronously using a single worker thread.
20 class CC_EXPORT SingleThreadTaskGraphRunner
21 : public TaskGraphRunner,
22 public base::DelegateSimpleThread::Delegate {
23 public:
24 SingleThreadTaskGraphRunner();
25 ~SingleThreadTaskGraphRunner() override;
26
27 // Overridden from TaskGraphRunner:
28 void ScheduleTasks(NamespaceToken token, TaskGraph* graph) override;
29 void WaitForTasksToFinishRunning(NamespaceToken token) override;
30 void CollectCompletedTasks(NamespaceToken token,
31 Task::Vector* completed_tasks) override;
32
33 // Overridden from base::DelegateSimpleThread::Delegate:
34 void Run() override;
35
36 void Start(const std::string& thread_name);
37 void Shutdown();
38
39 private:
40 void RunTaskWithLockAcquired();
41
42 scoped_ptr<base::SimpleThread> raster_thread_;
reveman 2015/11/19 16:05:46 nit: s/raster_thread_/thread_/ as this is not stri
ericrk 2015/11/23 18:43:37 Done.
ericrk 2015/11/23 18:43:37 Done.
43
44 // Lock to exclusively access all the following members that are used to
45 // implement the TaskRunner interfaces.
46 base::Lock lock_;
47
48 // Stores the actual tasks to be run by this runner, sorted by priority.
49 TaskGraphWorkQueue work_queue_;
50
51 // Condition variable that is waited on by Run() until new tasks are ready to
52 // run or shutdown starts.
53 base::ConditionVariable has_ready_to_run_tasks_cv_;
54
55 // Condition variable that is waited on by origin threads until a namespace
56 // has finished running all associated tasks.
57 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_;
58
59 // Set during shutdown. Tells Run() to return when no more tasks are pending.
60 bool shutdown_;
61 };
62
63 } // namespace cc
64
65 #endif // CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698