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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 } | 1117 } |
1118 | 1118 |
1119 base::StaticAtomicSequenceNumber | 1119 base::StaticAtomicSequenceNumber |
1120 SequencedWorkerPool::Inner::g_last_sequence_number_; | 1120 SequencedWorkerPool::Inner::g_last_sequence_number_; |
1121 | 1121 |
1122 // SequencedWorkerPool -------------------------------------------------------- | 1122 // SequencedWorkerPool -------------------------------------------------------- |
1123 | 1123 |
1124 // static | 1124 // static |
1125 SequencedWorkerPool::SequenceToken | 1125 SequencedWorkerPool::SequenceToken |
1126 SequencedWorkerPool::GetSequenceTokenForCurrentThread() { | 1126 SequencedWorkerPool::GetSequenceTokenForCurrentThread() { |
| 1127 // Don't construct lazy instance on check. |
| 1128 if (g_lazy_tls_ptr == NULL) |
| 1129 return SequenceToken(); |
| 1130 |
1127 SequencedWorkerPool::SequenceToken* token = g_lazy_tls_ptr.Get().Get(); | 1131 SequencedWorkerPool::SequenceToken* token = g_lazy_tls_ptr.Get().Get(); |
1128 if (!token) | 1132 if (!token) |
1129 return SequenceToken(); | 1133 return SequenceToken(); |
1130 return *token; | 1134 return *token; |
1131 } | 1135 } |
1132 | 1136 |
1133 SequencedWorkerPool::SequencedWorkerPool( | 1137 SequencedWorkerPool::SequencedWorkerPool( |
1134 size_t max_threads, | 1138 size_t max_threads, |
1135 const std::string& thread_name_prefix) | 1139 const std::string& thread_name_prefix) |
1136 : constructor_message_loop_(MessageLoopProxy::current()), | 1140 : constructor_message_loop_(MessageLoopProxy::current()), |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { | 1278 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { |
1275 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); | 1279 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); |
1276 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); | 1280 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); |
1277 } | 1281 } |
1278 | 1282 |
1279 bool SequencedWorkerPool::IsShutdownInProgress() { | 1283 bool SequencedWorkerPool::IsShutdownInProgress() { |
1280 return inner_->IsShutdownInProgress(); | 1284 return inner_->IsShutdownInProgress(); |
1281 } | 1285 } |
1282 | 1286 |
1283 } // namespace base | 1287 } // namespace base |
OLD | NEW |