| 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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 } | 791 } |
| 792 } else { | 792 } else { |
| 793 // When we're terminating and there's no more work, we can | 793 // When we're terminating and there's no more work, we can |
| 794 // shut down, other workers can complete any pending or new tasks. | 794 // shut down, other workers can complete any pending or new tasks. |
| 795 // We can get additional tasks posted after shutdown_called_ is set | 795 // We can get additional tasks posted after shutdown_called_ is set |
| 796 // but only worker threads are allowed to post tasks at that time, and | 796 // but only worker threads are allowed to post tasks at that time, and |
| 797 // the workers responsible for posting those tasks will be available | 797 // the workers responsible for posting those tasks will be available |
| 798 // to run them. Also, there may be some tasks stuck behind running | 798 // to run them. Also, there may be some tasks stuck behind running |
| 799 // ones with the same sequence token, but additional threads won't | 799 // ones with the same sequence token, but additional threads won't |
| 800 // help this case. | 800 // help this case. |
| 801 if (shutdown_called_ && | 801 if (shutdown_called_ && blocking_shutdown_pending_task_count_ == 0) { |
| 802 blocking_shutdown_pending_task_count_ == 0) | 802 AutoUnlock unlock(lock_); |
| 803 delete_these_outside_lock.clear(); |
| 803 break; | 804 break; |
| 805 } |
| 804 waiting_thread_count_++; | 806 waiting_thread_count_++; |
| 805 | 807 |
| 806 switch (status) { | 808 switch (status) { |
| 807 case GET_WORK_NOT_FOUND: | 809 case GET_WORK_NOT_FOUND: |
| 808 has_work_cv_.Wait(); | 810 has_work_cv_.Wait(); |
| 809 break; | 811 break; |
| 810 case GET_WORK_WAIT: | 812 case GET_WORK_WAIT: |
| 811 has_work_cv_.TimedWait(wait_time); | 813 has_work_cv_.TimedWait(wait_time); |
| 812 break; | 814 break; |
| 813 default: | 815 default: |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { | 1275 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { |
| 1274 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); | 1276 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); |
| 1275 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); | 1277 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); |
| 1276 } | 1278 } |
| 1277 | 1279 |
| 1278 bool SequencedWorkerPool::IsShutdownInProgress() { | 1280 bool SequencedWorkerPool::IsShutdownInProgress() { |
| 1279 return inner_->IsShutdownInProgress(); | 1281 return inner_->IsShutdownInProgress(); |
| 1280 } | 1282 } |
| 1281 | 1283 |
| 1282 } // namespace base | 1284 } // namespace base |
| OLD | NEW |