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