OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_ | 5 #ifndef CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_ |
6 #define CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_ | 6 #define CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/synchronization/condition_variable.h" | 9 #include "base/synchronization/condition_variable.h" |
10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 Task::Vector* completed_tasks) override; | 33 Task::Vector* completed_tasks) override; |
34 | 34 |
35 // Overridden from base::DelegateSimpleThread::Delegate: | 35 // Overridden from base::DelegateSimpleThread::Delegate: |
36 void Run() override; | 36 void Run() override; |
37 | 37 |
38 void Start(const std::string& thread_name, | 38 void Start(const std::string& thread_name, |
39 const base::SimpleThread::Options& thread_options); | 39 const base::SimpleThread::Options& thread_options); |
40 void Shutdown(); | 40 void Shutdown(); |
41 | 41 |
42 private: | 42 private: |
43 void RunTaskWithLockAcquired(); | 43 // Returns true if there was a task to run. |
| 44 bool RunTaskWithLockAcquired(); |
44 | 45 |
45 scoped_ptr<base::SimpleThread> thread_; | 46 scoped_ptr<base::SimpleThread> thread_; |
46 | 47 |
47 // Lock to exclusively access all the following members that are used to | 48 // Lock to exclusively access all the following members that are used to |
48 // implement the TaskRunner interfaces. | 49 // implement the TaskRunner interfaces. |
49 base::Lock lock_; | 50 base::Lock lock_; |
50 | 51 |
51 // Stores the actual tasks to be run by this runner, sorted by priority. | 52 // Stores the actual tasks to be run by this runner, sorted by priority. |
52 TaskGraphWorkQueue work_queue_; | 53 TaskGraphWorkQueue work_queue_; |
53 | 54 |
54 // Condition variable that is waited on by Run() until new tasks are ready to | 55 // Condition variable that is waited on by Run() until new tasks are ready to |
55 // run or shutdown starts. | 56 // run or shutdown starts. |
56 base::ConditionVariable has_ready_to_run_tasks_cv_; | 57 base::ConditionVariable has_ready_to_run_tasks_cv_; |
57 | 58 |
58 // Condition variable that is waited on by origin threads until a namespace | 59 // Condition variable that is waited on by origin threads until a namespace |
59 // has finished running all associated tasks. | 60 // has finished running all associated tasks. |
60 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; | 61 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; |
61 | 62 |
62 // Set during shutdown. Tells Run() to return when no more tasks are pending. | 63 // Set during shutdown. Tells Run() to return when no more tasks are pending. |
63 bool shutdown_; | 64 bool shutdown_; |
64 }; | 65 }; |
65 | 66 |
66 } // namespace cc | 67 } // namespace cc |
67 | 68 |
68 #endif // CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_ | 69 #endif // CC_RASTER_SINGLE_THREAD_TASK_GRAPH_RUNNER_H_ |
OLD | NEW |