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

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

Issue 2389923004: Allow BLOCK_SHUTDOWN tasks during shutdown with SequencedWorkerPool redirected to TaskScheduler. (Closed)
Patch Set: CR gab #5 Created 4 years, 2 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 int max_new_blocking_tasks_after_shutdown) { 917 int max_new_blocking_tasks_after_shutdown) {
918 DCHECK_GE(max_new_blocking_tasks_after_shutdown, 0); 918 DCHECK_GE(max_new_blocking_tasks_after_shutdown, 0);
919 { 919 {
920 AutoLock lock(lock_); 920 AutoLock lock(lock_);
921 // Cleanup and Shutdown should not be called concurrently. 921 // Cleanup and Shutdown should not be called concurrently.
922 CHECK_EQ(CLEANUP_DONE, cleanup_state_); 922 CHECK_EQ(CLEANUP_DONE, cleanup_state_);
923 if (shutdown_called_) 923 if (shutdown_called_)
924 return; 924 return;
925 shutdown_called_ = true; 925 shutdown_called_ = true;
926 926
927 max_blocking_tasks_after_shutdown_ = max_new_blocking_tasks_after_shutdown;
928
927 if (subtle::NoBarrier_Load(&g_all_pools_state) != 929 if (subtle::NoBarrier_Load(&g_all_pools_state) !=
928 AllPoolsState::WORKER_CREATED) 930 AllPoolsState::WORKER_CREATED) {
929 return; 931 return;
930 932 }
931 max_blocking_tasks_after_shutdown_ = max_new_blocking_tasks_after_shutdown;
932 933
933 // Tickle the threads. This will wake up a waiting one so it will know that 934 // Tickle the threads. This will wake up a waiting one so it will know that
934 // it can exit, which in turn will wake up any other waiting ones. 935 // it can exit, which in turn will wake up any other waiting ones.
935 SignalHasWork(); 936 SignalHasWork();
936 937
937 // There are no pending or running tasks blocking shutdown, we're done. 938 // There are no pending or running tasks blocking shutdown, we're done.
938 if (CanShutdown()) 939 if (CanShutdown())
939 return; 940 return;
940 } 941 }
941 942
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 bool SequencedWorkerPool::IsShutdownInProgress() { 1621 bool SequencedWorkerPool::IsShutdownInProgress() {
1621 return inner_->IsShutdownInProgress(); 1622 return inner_->IsShutdownInProgress();
1622 } 1623 }
1623 1624
1624 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( 1625 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread(
1625 SequenceToken sequence_token) const { 1626 SequenceToken sequence_token) const {
1626 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); 1627 return inner_->IsRunningSequenceOnCurrentThread(sequence_token);
1627 } 1628 }
1628 1629
1629 } // namespace base 1630 } // 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