| 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/resources/worker_pool.h" | 5 #include "cc/resources/worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 383 } |
| 384 | 384 |
| 385 void WorkerPool::Shutdown() { | 385 void WorkerPool::Shutdown() { |
| 386 TRACE_EVENT0("cc", "WorkerPool::Shutdown"); | 386 TRACE_EVENT0("cc", "WorkerPool::Shutdown"); |
| 387 | 387 |
| 388 DCHECK(!in_dispatch_completion_callbacks_); | 388 DCHECK(!in_dispatch_completion_callbacks_); |
| 389 | 389 |
| 390 inner_->Shutdown(); | 390 inner_->Shutdown(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 void WorkerPool::CheckForCompletedTasks() { | 393 void WorkerPool::SetTaskGraph(TaskGraph* graph) { |
| 394 TRACE_EVENT0("cc", "WorkerPool::CheckForCompletedTasks"); | 394 TRACE_EVENT1("cc", "WorkerPool::SetTaskGraph", |
| 395 "num_tasks", graph->size()); |
| 395 | 396 |
| 396 DCHECK(!in_dispatch_completion_callbacks_); | 397 DCHECK(!in_dispatch_completion_callbacks_); |
| 397 | 398 |
| 399 inner_->SetTaskGraph(graph); |
| 400 } |
| 401 |
| 402 void WorkerPool::CheckForCompletedWorkerTasks() { |
| 403 TRACE_EVENT0("cc", "WorkerPool::CheckForCompletedWorkerTasks"); |
| 404 |
| 405 DCHECK(!in_dispatch_completion_callbacks_); |
| 406 |
| 398 TaskVector completed_tasks; | 407 TaskVector completed_tasks; |
| 399 inner_->CollectCompletedTasks(&completed_tasks); | 408 inner_->CollectCompletedTasks(&completed_tasks); |
| 400 ProcessCompletedTasks(completed_tasks); | 409 ProcessCompletedTasks(completed_tasks); |
| 401 } | 410 } |
| 402 | 411 |
| 403 void WorkerPool::ProcessCompletedTasks( | 412 void WorkerPool::ProcessCompletedTasks( |
| 404 const TaskVector& completed_tasks) { | 413 const TaskVector& completed_tasks) { |
| 405 TRACE_EVENT1("cc", "WorkerPool::ProcessCompletedTasks", | 414 TRACE_EVENT1("cc", "WorkerPool::ProcessCompletedTasks", |
| 406 "completed_task_count", completed_tasks.size()); | 415 "completed_task_count", completed_tasks.size()); |
| 407 | 416 |
| 408 // Worker pool instance is not reentrant while processing completed tasks. | 417 // Worker pool instance is not reentrant while processing completed tasks. |
| 409 in_dispatch_completion_callbacks_ = true; | 418 in_dispatch_completion_callbacks_ = true; |
| 410 | 419 |
| 411 for (TaskVector::const_iterator it = completed_tasks.begin(); | 420 for (TaskVector::const_iterator it = completed_tasks.begin(); |
| 412 it != completed_tasks.end(); | 421 it != completed_tasks.end(); |
| 413 ++it) { | 422 ++it) { |
| 414 internal::WorkerPoolTask* task = it->get(); | 423 internal::WorkerPoolTask* task = it->get(); |
| 415 | 424 |
| 416 task->WillComplete(); | 425 task->WillComplete(); |
| 417 task->CompleteOnOriginThread(); | 426 task->CompleteOnOriginThread(); |
| 418 task->DidComplete(); | 427 task->DidComplete(); |
| 419 } | 428 } |
| 420 | 429 |
| 421 in_dispatch_completion_callbacks_ = false; | 430 in_dispatch_completion_callbacks_ = false; |
| 422 } | 431 } |
| 423 | 432 |
| 424 void WorkerPool::SetTaskGraph(TaskGraph* graph) { | |
| 425 TRACE_EVENT1("cc", "WorkerPool::SetTaskGraph", | |
| 426 "num_tasks", graph->size()); | |
| 427 | |
| 428 DCHECK(!in_dispatch_completion_callbacks_); | |
| 429 | |
| 430 inner_->SetTaskGraph(graph); | |
| 431 } | |
| 432 | |
| 433 } // namespace cc | 433 } // namespace cc |
| OLD | NEW |