| 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 #include "content/renderer/raster_worker_pool.h" | 5 #include "content/renderer/raster_worker_pool.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 TRACE_EVENT0("toplevel", "TaskGraphRunner::RunTask"); | 345 TRACE_EVENT0("toplevel", "TaskGraphRunner::RunTask"); |
| 346 | 346 |
| 347 lock_.AssertAcquired(); | 347 lock_.AssertAcquired(); |
| 348 | 348 |
| 349 auto prioritized_task = work_queue_.GetNextTaskToRun(category); | 349 auto prioritized_task = work_queue_.GetNextTaskToRun(category); |
| 350 cc::Task* task = prioritized_task.task; | 350 cc::Task* task = prioritized_task.task; |
| 351 | 351 |
| 352 // There may be more work available, so wake up another worker thread. | 352 // There may be more work available, so wake up another worker thread. |
| 353 SignalHasReadyToRunTasksWithLockAcquired(); | 353 SignalHasReadyToRunTasksWithLockAcquired(); |
| 354 | 354 |
| 355 // Call WillRun() before releasing |lock_| and running task. | |
| 356 task->WillRun(); | |
| 357 | |
| 358 { | 355 { |
| 359 base::AutoUnlock unlock(lock_); | 356 base::AutoUnlock unlock(lock_); |
| 360 | 357 |
| 361 task->RunOnWorkerThread(); | 358 task->RunOnWorkerThread(); |
| 362 } | 359 } |
| 363 | 360 |
| 364 // This will mark task as finished running. | |
| 365 task->DidRun(); | |
| 366 | |
| 367 work_queue_.CompleteTask(prioritized_task); | 361 work_queue_.CompleteTask(prioritized_task); |
| 368 | 362 |
| 369 // If namespace has finished running all tasks, wake up origin threads. | 363 // If namespace has finished running all tasks, wake up origin threads. |
| 370 if (work_queue_.HasFinishedRunningTasksInNamespace( | 364 if (work_queue_.HasFinishedRunningTasksInNamespace( |
| 371 prioritized_task.task_namespace)) | 365 prioritized_task.task_namespace)) |
| 372 has_namespaces_with_finished_running_tasks_cv_.Signal(); | 366 has_namespaces_with_finished_running_tasks_cv_.Signal(); |
| 373 } | 367 } |
| 374 | 368 |
| 375 bool RasterWorkerPool::ShouldRunTaskForCategoryWithLockAcquired( | 369 bool RasterWorkerPool::ShouldRunTaskForCategoryWithLockAcquired( |
| 376 cc::TaskCategory category) { | 370 cc::TaskCategory category) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 418 |
| 425 // Overridden from cc::Task: | 419 // Overridden from cc::Task: |
| 426 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { | 420 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { |
| 427 closure_.Run(); | 421 closure_.Run(); |
| 428 closure_.Reset(); | 422 closure_.Reset(); |
| 429 } | 423 } |
| 430 | 424 |
| 431 RasterWorkerPool::ClosureTask::~ClosureTask() {} | 425 RasterWorkerPool::ClosureTask::~ClosureTask() {} |
| 432 | 426 |
| 433 } // namespace content | 427 } // namespace content |
| OLD | NEW |