Chromium Code Reviews| Index: content/renderer/raster_worker_pool.cc |
| diff --git a/content/renderer/raster_worker_pool.cc b/content/renderer/raster_worker_pool.cc |
| index 71859d846b6b88e9e890f1b9702b58586ec188f2..95a226120fecb004a58f3b6a21e71b6210c105fd 100644 |
| --- a/content/renderer/raster_worker_pool.cc |
| +++ b/content/renderer/raster_worker_pool.cc |
| @@ -120,35 +120,45 @@ RasterWorkerPool::RasterWorkerPool() |
| has_namespaces_with_finished_running_tasks_cv_(&lock_), |
| shutdown_(false) {} |
| -void RasterWorkerPool::Start( |
| - int num_threads, |
| - const base::SimpleThread::Options& thread_options) { |
| +void RasterWorkerPool::Start(int num_foreground_threads) { |
| DCHECK(threads_.empty()); |
| - while (threads_.size() < static_cast<size_t>(num_threads)) { |
| - // Determine the categories that each thread can run. |
| + |
| + while (threads_.size() < static_cast<size_t>(num_foreground_threads)) { |
| + // Determine the categories that each foreground thread can run. |
| std::vector<cc::TaskCategory> task_categories; |
| // The first thread can run nonconcurrent tasks. |
| - if (threads_.size() == 0) { |
| + if (!threads_.size()) { |
| task_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); |
| } |
| // All threads can run foreground tasks. |
| task_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); |
| - // The last thread can run background tasks. |
| - if (threads_.size() == (static_cast<size_t>(num_threads) - 1)) { |
| - task_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); |
| - } |
| - |
| - scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
| + scoped_ptr<base::SimpleThread> foreground_thread(new RasterWorkerPoolThread( |
| base::StringPrintf("CompositorTileWorker%u", |
| static_cast<unsigned>(threads_.size() + 1)) |
| .c_str(), |
| - thread_options, this, task_categories)); |
| - thread->Start(); |
| - threads_.push_back(std::move(thread)); |
| + base::SimpleThread::Options(), this, task_categories)); |
| + foreground_thread->Start(); |
| + threads_.push_back(std::move(foreground_thread)); |
| } |
| + |
| + // Background thread can only run background tasks. |
|
ericrk
2016/01/26 22:39:56
I like this idea in general, but a few questions:
|
| + std::vector<cc::TaskCategory> background_task_categories; |
| + background_task_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); |
| + |
| + // Use background priority for background thread. |
| + base::SimpleThread::Options thread_options; |
| + thread_options.set_priority(base::ThreadPriority::BACKGROUND); |
| + |
| + scoped_ptr<base::SimpleThread> background_thread(new RasterWorkerPoolThread( |
| + base::StringPrintf("CompositorTileWorker%u", |
| + static_cast<unsigned>(threads_.size() + 1)) |
| + .c_str(), |
| + thread_options, this, background_task_categories)); |
| + background_thread->Start(); |
| + threads_.push_back(std::move(background_thread)); |
| } |
| void RasterWorkerPool::Shutdown() { |