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

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

Issue 10151009: Disallow UI/IO thread blocking on any other thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « base/test/thread_test_helper.cc ('k') | base/threading/simple_thread.h » ('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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/message_loop_proxy.h" 18 #include "base/message_loop_proxy.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/stl_util.h" 20 #include "base/stl_util.h"
21 #include "base/stringprintf.h" 21 #include "base/stringprintf.h"
22 #include "base/synchronization/condition_variable.h" 22 #include "base/synchronization/condition_variable.h"
23 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
24 #include "base/threading/platform_thread.h" 24 #include "base/threading/platform_thread.h"
25 #include "base/threading/simple_thread.h" 25 #include "base/threading/simple_thread.h"
26 #include "base/threading/thread_restrictions.h"
26 #include "base/time.h" 27 #include "base/time.h"
27 #include "base/tracked_objects.h" 28 #include "base/tracked_objects.h"
28 29
29 #if defined(OS_MACOSX) 30 #if defined(OS_MACOSX)
30 #include "base/mac/scoped_nsautorelease_pool.h" 31 #include "base/mac/scoped_nsautorelease_pool.h"
31 #endif 32 #endif
32 33
33 namespace base { 34 namespace base {
34 35
35 namespace { 36 namespace {
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 619
619 // If we're here, then something is blocking shutdown. So wait for 620 // If we're here, then something is blocking shutdown. So wait for
620 // CanShutdown() to go to true. 621 // CanShutdown() to go to true.
621 622
622 if (testing_observer_) 623 if (testing_observer_)
623 testing_observer_->WillWaitForShutdown(); 624 testing_observer_->WillWaitForShutdown();
624 625
625 TimeTicks shutdown_wait_begin = TimeTicks::Now(); 626 TimeTicks shutdown_wait_begin = TimeTicks::Now();
626 627
627 { 628 {
629 base::ThreadRestrictions::ScopedAllowWait allow_wait;
628 AutoLock lock(lock_); 630 AutoLock lock(lock_);
629 while (!CanShutdown()) 631 while (!CanShutdown())
630 can_shutdown_cv_.Wait(); 632 can_shutdown_cv_.Wait();
631 } 633 }
632 UMA_HISTOGRAM_TIMES("SequencedWorkerPool.ShutdownDelayTime", 634 UMA_HISTOGRAM_TIMES("SequencedWorkerPool.ShutdownDelayTime",
633 TimeTicks::Now() - shutdown_wait_begin); 635 TimeTicks::Now() - shutdown_wait_begin);
634 } 636 }
635 637
636 void SequencedWorkerPool::Inner::ThreadLoop(Worker* this_worker) { 638 void SequencedWorkerPool::Inner::ThreadLoop(Worker* this_worker) {
637 { 639 {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 void SequencedWorkerPool::SignalHasWorkForTesting() { 1064 void SequencedWorkerPool::SignalHasWorkForTesting() {
1063 inner_->SignalHasWorkForTesting(); 1065 inner_->SignalHasWorkForTesting();
1064 } 1066 }
1065 1067
1066 void SequencedWorkerPool::Shutdown() { 1068 void SequencedWorkerPool::Shutdown() {
1067 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); 1069 DCHECK(constructor_message_loop_->BelongsToCurrentThread());
1068 inner_->Shutdown(); 1070 inner_->Shutdown();
1069 } 1071 }
1070 1072
1071 } // namespace base 1073 } // namespace base
OLDNEW
« no previous file with comments | « base/test/thread_test_helper.cc ('k') | base/threading/simple_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698