| 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 CONTENT_RENDERER_RASTER_WORKER_POOL_H_ | 5 #ifndef CONTENT_RENDERER_RASTER_WORKER_POOL_H_ |
| 6 #define CONTENT_RENDERER_RASTER_WORKER_POOL_H_ | 6 #define CONTENT_RENDERER_RASTER_WORKER_POOL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 // Helper function which signals worker threads if tasks are ready to run. | 110 // Helper function which signals worker threads if tasks are ready to run. |
| 111 void SignalHasReadyToRunTasksWithLockAcquired(); | 111 void SignalHasReadyToRunTasksWithLockAcquired(); |
| 112 | 112 |
| 113 // Determines if we should run a new task for the given category. This factors | 113 // Determines if we should run a new task for the given category. This factors |
| 114 // in whether a task is available and whether the count of running tasks is | 114 // in whether a task is available and whether the count of running tasks is |
| 115 // low enough to start a new one. | 115 // low enough to start a new one. |
| 116 bool ShouldRunTaskForCategoryWithLockAcquired(cc::TaskCategory category); | 116 bool ShouldRunTaskForCategoryWithLockAcquired(cc::TaskCategory category); |
| 117 | 117 |
| 118 // The actual threads where work is done. | 118 // The actual threads where work is done. |
| 119 std::vector<scoped_ptr<base::SimpleThread>> threads_; | 119 std::vector<std::unique_ptr<base::SimpleThread>> threads_; |
| 120 | 120 |
| 121 // Lock to exclusively access all the following members that are used to | 121 // Lock to exclusively access all the following members that are used to |
| 122 // implement the TaskRunner and TaskGraphRunner interfaces. | 122 // implement the TaskRunner and TaskGraphRunner interfaces. |
| 123 base::Lock lock_; | 123 base::Lock lock_; |
| 124 // Stores the tasks to be run, sorted by priority. | 124 // Stores the tasks to be run, sorted by priority. |
| 125 cc::TaskGraphWorkQueue work_queue_; | 125 cc::TaskGraphWorkQueue work_queue_; |
| 126 // Namespace used to schedule tasks in the task graph runner. | 126 // Namespace used to schedule tasks in the task graph runner. |
| 127 cc::NamespaceToken namespace_token_; | 127 cc::NamespaceToken namespace_token_; |
| 128 // List of tasks currently queued up for execution. | 128 // List of tasks currently queued up for execution. |
| 129 cc::Task::Vector tasks_; | 129 cc::Task::Vector tasks_; |
| 130 // Graph object used for scheduling tasks. | 130 // Graph object used for scheduling tasks. |
| 131 cc::TaskGraph graph_; | 131 cc::TaskGraph graph_; |
| 132 // Cached vector to avoid allocation when getting the list of complete | 132 // Cached vector to avoid allocation when getting the list of complete |
| 133 // tasks. | 133 // tasks. |
| 134 cc::Task::Vector completed_tasks_; | 134 cc::Task::Vector completed_tasks_; |
| 135 // Condition variables for foreground and background tasks. | 135 // Condition variables for foreground and background tasks. |
| 136 base::ConditionVariable has_ready_to_run_foreground_tasks_cv_; | 136 base::ConditionVariable has_ready_to_run_foreground_tasks_cv_; |
| 137 base::ConditionVariable has_ready_to_run_background_tasks_cv_; | 137 base::ConditionVariable has_ready_to_run_background_tasks_cv_; |
| 138 // Condition variable that is waited on by origin threads until a namespace | 138 // Condition variable that is waited on by origin threads until a namespace |
| 139 // has finished running all associated tasks. | 139 // has finished running all associated tasks. |
| 140 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; | 140 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; |
| 141 // Set during shutdown. Tells Run() to return when no more tasks are pending. | 141 // Set during shutdown. Tells Run() to return when no more tasks are pending. |
| 142 bool shutdown_; | 142 bool shutdown_; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 } // namespace content | 145 } // namespace content |
| 146 | 146 |
| 147 #endif // CONTENT_RENDERER_RASTER_WORKER_POOL_H_ | 147 #endif // CONTENT_RENDERER_RASTER_WORKER_POOL_H_ |
| OLD | NEW |