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/worker_pool_posix.h" | 5 #include "base/threading/worker_pool_posix.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 void PosixDynamicThreadPool::PostTask( | 141 void PosixDynamicThreadPool::PostTask( |
142 const tracked_objects::Location& from_here, | 142 const tracked_objects::Location& from_here, |
143 base::OnceClosure task) { | 143 base::OnceClosure task) { |
144 PendingTask pending_task(from_here, std::move(task)); | 144 PendingTask pending_task(from_here, std::move(task)); |
145 AddTask(&pending_task); | 145 AddTask(&pending_task); |
146 } | 146 } |
147 | 147 |
148 void PosixDynamicThreadPool::AddTask(PendingTask* pending_task) { | 148 void PosixDynamicThreadPool::AddTask(PendingTask* pending_task) { |
149 DCHECK(pending_task); | 149 DCHECK(pending_task); |
150 DCHECK(pending_task->task); | 150 |
| 151 // Use CHECK instead of DCHECK to crash earlier. See http://crbug.com/711167 |
| 152 // for details. |
| 153 CHECK(pending_task->task); |
| 154 |
151 AutoLock locked(lock_); | 155 AutoLock locked(lock_); |
152 | 156 |
153 pending_tasks_.push(std::move(*pending_task)); | 157 pending_tasks_.push(std::move(*pending_task)); |
154 | 158 |
155 // We have enough worker threads. | 159 // We have enough worker threads. |
156 if (static_cast<size_t>(num_idle_threads_) >= pending_tasks_.size()) { | 160 if (static_cast<size_t>(num_idle_threads_) >= pending_tasks_.size()) { |
157 pending_tasks_available_cv_.Signal(); | 161 pending_tasks_available_cv_.Signal(); |
158 } else { | 162 } else { |
159 // The new PlatformThread will take ownership of the WorkerThread object, | 163 // The new PlatformThread will take ownership of the WorkerThread object, |
160 // which will delete itself on exit. | 164 // which will delete itself on exit. |
(...skipping 20 matching lines...) Expand all Loading... |
181 return PendingTask(FROM_HERE, base::Closure()); | 185 return PendingTask(FROM_HERE, base::Closure()); |
182 } | 186 } |
183 } | 187 } |
184 | 188 |
185 PendingTask pending_task = std::move(pending_tasks_.front()); | 189 PendingTask pending_task = std::move(pending_tasks_.front()); |
186 pending_tasks_.pop(); | 190 pending_tasks_.pop(); |
187 return pending_task; | 191 return pending_task; |
188 } | 192 } |
189 | 193 |
190 } // namespace base | 194 } // namespace base |
OLD | NEW |