Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: base/threading/sequenced_worker_pool.cc

Issue 994483005: Base: Fix another deadlock during shutdown of SequencedWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_ && blocking_shutdown_pending_task_count_ == 0) { 801 if (shutdown_called_ && blocking_shutdown_pending_task_count_ == 0) {
802 AutoUnlock unlock(lock_); 802 AutoUnlock unlock(lock_);
803 delete_these_outside_lock.clear(); 803 delete_these_outside_lock.clear();
804 break; 804 break;
805 } 805 }
806
807 // No work was found, but there are tasks that need deletion. The
808 // deletion must happen outside of the lock. Since the lock has been
brettw 2015/03/12 23:12:42 I don't follow this, maybe the comment needs to be
erikchen 2015/03/12 23:24:52 I broke the comment in two, moved the location of
809 // released, the current state about whether there is more work is no
810 // longer valid, and needs to be recalculated by jumping to the top of
811 // the loop.
812 if (delete_these_outside_lock.size()) {
813 AutoUnlock unlock(lock_);
814 delete_these_outside_lock.clear();
815 continue;
816 }
817
806 waiting_thread_count_++; 818 waiting_thread_count_++;
807 819
808 switch (status) { 820 switch (status) {
809 case GET_WORK_NOT_FOUND: 821 case GET_WORK_NOT_FOUND:
810 has_work_cv_.Wait(); 822 has_work_cv_.Wait();
811 break; 823 break;
812 case GET_WORK_WAIT: 824 case GET_WORK_WAIT:
813 has_work_cv_.TimedWait(wait_time); 825 has_work_cv_.TimedWait(wait_time);
814 break; 826 break;
815 default: 827 default:
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { 1287 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) {
1276 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); 1288 DCHECK(constructor_message_loop_->BelongsToCurrentThread());
1277 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); 1289 inner_->Shutdown(max_new_blocking_tasks_after_shutdown);
1278 } 1290 }
1279 1291
1280 bool SequencedWorkerPool::IsShutdownInProgress() { 1292 bool SequencedWorkerPool::IsShutdownInProgress() {
1281 return inner_->IsShutdownInProgress(); 1293 return inner_->IsShutdownInProgress();
1282 } 1294 }
1283 1295
1284 } // namespace base 1296 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698