diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 21:52:36 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 21:52:36 +0000 |
commit | f3fbddcfc93d477c9813ce81f74a99284d90f830 (patch) | |
tree | d6764539c2e011186eb223c2906a8652e42aecaf /base | |
parent | 066f376288364c74520a61115b35f7315e8cd401 (diff) | |
download | chromium_src-f3fbddcfc93d477c9813ce81f74a99284d90f830.zip chromium_src-f3fbddcfc93d477c9813ce81f74a99284d90f830.tar.gz chromium_src-f3fbddcfc93d477c9813ce81f74a99284d90f830.tar.bz2 |
Merge r46124 from the trunk to the 375 branch.
Throw something at the wall. See what sticks.
This is an attempt to fix or defer WorkerPoolMac pool stoppage.
1. Catch Objective-C exceptions thrown in task bodies.
2. Make sure the queue isn't suspended when posting tasks.
BUG=20471
TEST=none
Review URL: http://codereview.chromium.org/1699029
TBR=mark@chromium.org
Review URL: http://codereview.chromium.org/1718027
git-svn-id: svn://svn.chromium.org/chrome/branches/375/src@46126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/singleton_objc.h | 2 | ||||
-rw-r--r-- | base/worker_pool_mac.mm | 28 |
2 files changed, 28 insertions, 2 deletions
diff --git a/base/singleton_objc.h b/base/singleton_objc.h index ba9fc78..3ba5f1e 100644 --- a/base/singleton_objc.h +++ b/base/singleton_objc.h @@ -23,7 +23,7 @@ // static Foo* New() { // return [[Foo alloc] initWithName:@"selecty"]; // } -// } +// }; // ... // Foo* widgetSingleton = SingletonObjC<Foo, FooSingletonTraits>::get(); diff --git a/base/worker_pool_mac.mm b/base/worker_pool_mac.mm index 35d1079..9a9076e 100644 --- a/base/worker_pool_mac.mm +++ b/base/worker_pool_mac.mm @@ -11,6 +11,15 @@ #import "base/singleton_objc.h" #include "base/task.h" +// When C++ exceptions are disabled, the C++ library defines |try| and +// |catch| so as to allow exception-expecting C++ code to build properly when +// language support for exceptions is not present. These macros interfere +// with the use of |@try| and |@catch| in Objective-C files such as this one. +// Undefine these macros here, after everything has been #included, since +// there will be no C++ uses and only Objective-C uses from this point on. +#undef try +#undef catch + namespace { Lock lock_; @@ -75,7 +84,15 @@ size_t outstanding_ = 0; // Operations posted but not completed. base::ScopedNSAutoreleasePool autoreleasePool; - task_->Run(); + @try { + task_->Run(); + } @catch(NSException* exception) { + LOG(ERROR) << "-[TaskOperation main] caught an NSException: " + << [[exception description] UTF8String]; + } @catch(id exception) { + LOG(ERROR) << "-[TaskOperation main] caught an unknown exception"; + } + task_.reset(NULL); { @@ -111,6 +128,15 @@ bool WorkerPool::PostTask(const tracked_objects::Location& from_here, NSOperationQueue* operation_queue = [WorkerPoolObjC sharedOperationQueue]; [operation_queue addOperation:[TaskOperation taskOperationWithTask:task]]; + if ([operation_queue isSuspended]) { + LOG(WARNING) << "WorkerPool::PostTask freeing stuck NSOperationQueue"; + + // Nothing should ever be suspending this queue, but in case it winds up + // happening, free things up. This is a purely speculative shot in the + // dark for http://crbug.com/20471. + [operation_queue setSuspended:NO]; + } + // Periodically calculate the set of operations which have not made // progress and report how many there are. This should provide a // sense of how many clients are seeing hung operations of any sort, |