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

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

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.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 | « base/third_party/nspr/BUILD.gn ('k') | 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.
809 if (delete_these_outside_lock.size()) {
810 AutoUnlock unlock(lock_);
811 delete_these_outside_lock.clear();
812
813 // Since the lock has been released, |status| may no longer be
814 // accurate. It might read GET_WORK_WAIT even if there are tasks
815 // ready to perform work. Jump to the top of the loop to recalculate
816 // |status|.
817 continue;
818 }
819
806 waiting_thread_count_++; 820 waiting_thread_count_++;
807 821
808 switch (status) { 822 switch (status) {
809 case GET_WORK_NOT_FOUND: 823 case GET_WORK_NOT_FOUND:
810 has_work_cv_.Wait(); 824 has_work_cv_.Wait();
811 break; 825 break;
812 case GET_WORK_WAIT: 826 case GET_WORK_WAIT:
813 has_work_cv_.TimedWait(wait_time); 827 has_work_cv_.TimedWait(wait_time);
814 break; 828 break;
815 default: 829 default:
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { 1289 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) {
1276 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); 1290 DCHECK(constructor_message_loop_->BelongsToCurrentThread());
1277 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); 1291 inner_->Shutdown(max_new_blocking_tasks_after_shutdown);
1278 } 1292 }
1279 1293
1280 bool SequencedWorkerPool::IsShutdownInProgress() { 1294 bool SequencedWorkerPool::IsShutdownInProgress() {
1281 return inner_->IsShutdownInProgress(); 1295 return inner_->IsShutdownInProgress();
1282 } 1296 }
1283 1297
1284 } // namespace base 1298 } // namespace base
OLDNEW
« no previous file with comments | « base/third_party/nspr/BUILD.gn ('k') | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698