OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/threading/sequenced_worker_pool.h" | 5 #include "base/threading/sequenced_worker_pool.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "base/threading/platform_thread.h" | 25 #include "base/threading/platform_thread.h" |
26 #include "base/threading/simple_thread.h" | 26 #include "base/threading/simple_thread.h" |
27 #include "base/threading/thread_local.h" | 27 #include "base/threading/thread_local.h" |
28 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
29 #include "base/time/time.h" | 29 #include "base/time/time.h" |
30 #include "base/trace_event/trace_event.h" | 30 #include "base/trace_event/trace_event.h" |
31 #include "base/tracked_objects.h" | 31 #include "base/tracked_objects.h" |
32 | 32 |
33 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
34 #include "base/mac/scoped_nsautorelease_pool.h" | 34 #include "base/mac/scoped_nsautorelease_pool.h" |
35 #elif defined(OS_WIN) | |
36 #include "base/win/scoped_com_initializer.h" | |
37 #endif | 35 #endif |
38 | 36 |
39 #if !defined(OS_NACL) | 37 #if !defined(OS_NACL) |
40 #include "base/metrics/histogram.h" | 38 #include "base/metrics/histogram.h" |
41 #endif | 39 #endif |
42 | 40 |
43 namespace base { | 41 namespace base { |
44 | 42 |
45 namespace { | 43 namespace { |
46 | 44 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 worker_pool_(worker_pool), | 495 worker_pool_(worker_pool), |
498 task_shutdown_behavior_(BLOCK_SHUTDOWN), | 496 task_shutdown_behavior_(BLOCK_SHUTDOWN), |
499 is_processing_task_(false) { | 497 is_processing_task_(false) { |
500 Start(); | 498 Start(); |
501 } | 499 } |
502 | 500 |
503 SequencedWorkerPool::Worker::~Worker() { | 501 SequencedWorkerPool::Worker::~Worker() { |
504 } | 502 } |
505 | 503 |
506 void SequencedWorkerPool::Worker::Run() { | 504 void SequencedWorkerPool::Worker::Run() { |
507 #if defined(OS_WIN) | |
508 win::ScopedCOMInitializer com_initializer; | |
509 #endif | |
510 | |
511 // Store a pointer to the running sequence in thread local storage for | 505 // Store a pointer to the running sequence in thread local storage for |
512 // static function access. | 506 // static function access. |
513 g_lazy_tls_ptr.Get().Set(&task_sequence_token_); | 507 g_lazy_tls_ptr.Get().Set(&task_sequence_token_); |
514 | 508 |
515 // Just jump back to the Inner object to run the thread, since it has all the | 509 // Just jump back to the Inner object to run the thread, since it has all the |
516 // tracking information and queues. It might be more natural to implement | 510 // tracking information and queues. It might be more natural to implement |
517 // using DelegateSimpleThread and have Inner implement the Delegate to avoid | 511 // using DelegateSimpleThread and have Inner implement the Delegate to avoid |
518 // having these worker objects at all, but that method lacks the ability to | 512 // having these worker objects at all, but that method lacks the ability to |
519 // send thread-specific information easily to the thread loop. | 513 // send thread-specific information easily to the thread loop. |
520 worker_pool_->inner_->ThreadLoop(this); | 514 worker_pool_->inner_->ThreadLoop(this); |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { | 1292 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { |
1299 DCHECK(constructor_task_runner_->BelongsToCurrentThread()); | 1293 DCHECK(constructor_task_runner_->BelongsToCurrentThread()); |
1300 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); | 1294 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); |
1301 } | 1295 } |
1302 | 1296 |
1303 bool SequencedWorkerPool::IsShutdownInProgress() { | 1297 bool SequencedWorkerPool::IsShutdownInProgress() { |
1304 return inner_->IsShutdownInProgress(); | 1298 return inner_->IsShutdownInProgress(); |
1305 } | 1299 } |
1306 | 1300 |
1307 } // namespace base | 1301 } // namespace base |
OLD | NEW |