OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/worker_pool_posix.h" | 5 #include "base/threading/worker_pool_posix.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 const std::string& name_prefix, | 124 const std::string& name_prefix, |
125 int idle_seconds_before_exit) | 125 int idle_seconds_before_exit) |
126 : name_prefix_(name_prefix), | 126 : name_prefix_(name_prefix), |
127 idle_seconds_before_exit_(idle_seconds_before_exit), | 127 idle_seconds_before_exit_(idle_seconds_before_exit), |
128 pending_tasks_available_cv_(&lock_), | 128 pending_tasks_available_cv_(&lock_), |
129 num_idle_threads_(0), | 129 num_idle_threads_(0), |
130 terminated_(false), | 130 terminated_(false), |
131 num_idle_threads_cv_(NULL) {} | 131 num_idle_threads_cv_(NULL) {} |
132 | 132 |
133 PosixDynamicThreadPool::~PosixDynamicThreadPool() { | 133 PosixDynamicThreadPool::~PosixDynamicThreadPool() { |
134 while (!pending_tasks_.empty()) { | 134 while (!pending_tasks_.empty()) |
135 PendingTask pending_task = pending_tasks_.front(); | |
136 pending_tasks_.pop(); | 135 pending_tasks_.pop(); |
137 } | |
138 } | 136 } |
139 | 137 |
140 void PosixDynamicThreadPool::Terminate() { | 138 void PosixDynamicThreadPool::Terminate() { |
141 { | 139 { |
142 AutoLock locked(lock_); | 140 AutoLock locked(lock_); |
143 DCHECK(!terminated_) << "Thread pool is already terminated."; | 141 DCHECK(!terminated_) << "Thread pool is already terminated."; |
144 terminated_ = true; | 142 terminated_ = true; |
145 } | 143 } |
146 pending_tasks_available_cv_.Broadcast(); | 144 pending_tasks_available_cv_.Broadcast(); |
147 } | 145 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return PendingTask(FROM_HERE, base::Closure()); | 207 return PendingTask(FROM_HERE, base::Closure()); |
210 } | 208 } |
211 } | 209 } |
212 | 210 |
213 PendingTask pending_task = pending_tasks_.front(); | 211 PendingTask pending_task = pending_tasks_.front(); |
214 pending_tasks_.pop(); | 212 pending_tasks_.pop(); |
215 return pending_task; | 213 return pending_task; |
216 } | 214 } |
217 | 215 |
218 } // namespace base | 216 } // namespace base |
OLD | NEW |