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

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: 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
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/raster/single_thread_task_graph_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/synchronization/condition_variable.h"
10 #include "base/threading/simple_thread.h"
11 #include "cc/raster/task_graph_runner.h"
12 #include "cc/raster/task_graph_work_queue.h"
13
14 namespace base {
15 class SimpleThread;
16 }
17
18 namespace cc {
19
20 // Runs TaskGraphs asynchronously using a single worker thread.
21 class CC_EXPORT SingleThreadTaskGraphRunner
22 : public TaskGraphRunner,
23 public base::DelegateSimpleThread::Delegate {
24 public:
25 SingleThreadTaskGraphRunner();
26 ~SingleThreadTaskGraphRunner() override;
27
28 // Overridden from TaskGraphRunner:
29 NamespaceToken GetNamespaceToken() override;
30 void ScheduleTasks(NamespaceToken token, TaskGraph* graph) override;
31 void WaitForTasksToFinishRunning(NamespaceToken token) override;
32 void CollectCompletedTasks(NamespaceToken token,
33 Task::Vector* completed_tasks) override;
34
35 // Overridden from base::DelegateSimpleThread::Delegate:
36 void Run() override;
37
38 void Start(const std::string& thread_name,
39 const base::SimpleThread::Options& thread_options);
40 void Shutdown();
41
42 private:
43 void RunTaskWithLockAcquired();
44
45 scoped_ptr<base::SimpleThread> thread_;
46
47 // Lock to exclusively access all the following members that are used to
48 // implement the TaskRunner interfaces.
49 base::Lock lock_;
50
51 // Stores the actual tasks to be run by this runner, sorted by priority.
52 TaskGraphWorkQueue work_queue_;
53
54 // Condition variable that is waited on by Run() until new tasks are ready to
55 // run or shutdown starts.
56 base::ConditionVariable has_ready_to_run_tasks_cv_;
57
58 // Condition variable that is waited on by origin threads until a namespace
59 // has finished running all associated tasks.
60 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_;
61
62 // Set during shutdown. Tells Run() to return when no more tasks are pending.
63 bool shutdown_;
64 };
65
66 } // namespace cc
67
68 #endif // CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/raster/single_thread_task_graph_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698