OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "cc/base/worker_pool.h" | 5 #include "cc/base/worker_pool.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
9 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
10 #include "base/synchronization/condition_variable.h" | 12 #include "base/synchronization/condition_variable.h" |
11 #include "base/threading/simple_thread.h" | 13 #include "base/threading/simple_thread.h" |
12 | 14 |
13 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
14 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) | 16 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
15 #include <sys/resource.h> | 17 #include <sys/resource.h> |
16 #endif | 18 #endif |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 AppendCompletedTasksWithLockAcquired( | 339 AppendCompletedTasksWithLockAcquired( |
338 &worker_pool_on_origin_thread_->completed_tasks_); | 340 &worker_pool_on_origin_thread_->completed_tasks_); |
339 } | 341 } |
340 | 342 |
341 worker_pool_on_origin_thread_->OnIdle(); | 343 worker_pool_on_origin_thread_->OnIdle(); |
342 } | 344 } |
343 | 345 |
344 void WorkerPool::Inner::Run() { | 346 void WorkerPool::Inner::Run() { |
345 #if defined(OS_ANDROID) | 347 #if defined(OS_ANDROID) |
346 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) | 348 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
347 int nice_value = 10; // Idle priority. | 349 int nice_value = 10; // Idle priority. |
348 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); | 350 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); |
349 #endif | 351 #endif |
350 | |
351 { | 352 { |
352 base::AutoLock lock(lock_); | 353 base::AutoLock lock(lock_); |
353 | 354 |
354 // Get a unique thread index. | 355 // Get a unique thread index. |
355 int thread_index = next_thread_index_++; | 356 int thread_index = next_thread_index_++; |
356 | 357 |
357 while (true) { | 358 while (true) { |
358 if (pending_tasks_.empty()) { | 359 if (pending_tasks_.empty()) { |
359 // Exit when shutdown is set and no more tasks are pending. | 360 // Exit when shutdown is set and no more tasks are pending. |
360 if (shutdown_) | 361 if (shutdown_) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 TRACE_EVENT_INSTANT0("cc", "WorkerPool::RunCheapTasks check time"); | 562 TRACE_EVENT_INSTANT0("cc", "WorkerPool::RunCheapTasks check time"); |
562 CancelCheckForCompletedTasks(); | 563 CancelCheckForCompletedTasks(); |
563 DispatchCompletionCallbacks(); | 564 DispatchCompletionCallbacks(); |
564 // Schedule another check for completed tasks if not idle. | 565 // Schedule another check for completed tasks if not idle. |
565 if (!is_idle) | 566 if (!is_idle) |
566 ScheduleCheckForCompletedTasks(); | 567 ScheduleCheckForCompletedTasks(); |
567 } | 568 } |
568 } | 569 } |
569 | 570 |
570 } // namespace cc | 571 } // namespace cc |
OLD | NEW |