diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 23:15:58 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 23:15:58 +0000 |
commit | 56fedfa29f49ce793d3343525f120eaff5f2b752 (patch) | |
tree | a4b709a6fbc9587338f3fed58f5f885e8138486a /base/worker_pool_mac.mm | |
parent | 27bc9e8ac1922f88fbe003c9b050add4e27321b0 (diff) | |
download | chromium_src-56fedfa29f49ce793d3343525f120eaff5f2b752.zip chromium_src-56fedfa29f49ce793d3343525f120eaff5f2b752.tar.gz chromium_src-56fedfa29f49ce793d3343525f120eaff5f2b752.tar.bz2 |
[Mac] Use Linux WorkerPool code.
Adapts things to use the Linux WorkerPool code by default, with
--disable-linux-workerpool to switch back to the old version.
The old implementation uses NSOperationQueue, which is implemented in
terms of pthread workqueues. These are implicated by the stack traces
from the recent unit test flakiness. This change attempts to
influence that flakiness.
BUG=20471, 60426
TEST=Tree green.
Review URL: http://codereview.chromium.org/4595001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/worker_pool_mac.mm')
-rw-r--r-- | base/worker_pool_mac.mm | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/base/worker_pool_mac.mm b/base/worker_pool_mac.mm index 01c0a98..bbc7892 100644 --- a/base/worker_pool_mac.mm +++ b/base/worker_pool_mac.mm @@ -5,12 +5,13 @@ #include "base/worker_pool_mac.h" #include "base/logging.h" -#import "base/mac/scoped_nsautorelease_pool.h" +#include "base/mac/scoped_nsautorelease_pool.h" #include "base/metrics/histogram.h" #include "base/scoped_ptr.h" #import "base/singleton_objc.h" #include "base/task.h" #include "base/third_party/dynamic_annotations/dynamic_annotations.h" +#include "base/worker_pool_linux.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 @@ -23,6 +24,10 @@ namespace { +// |true| to use the Linux WorkerPool implementation for +// |WorkerPool::PostTask()|. +bool use_linux_workerpool_ = true; + Lock lock_; base::Time last_check_; // Last hung-test check. std::vector<id> outstanding_ops_; // Outstanding operations at last check. @@ -31,6 +36,14 @@ size_t outstanding_ = 0; // Operations posted but not completed. } // namespace +namespace worker_pool_mac { + +void SetUseLinuxWorkerPool(bool flag) { + use_linux_workerpool_ = flag; +} + +} // namespace worker_pool_mac + @implementation WorkerPoolObjC + (NSOperationQueue*)sharedOperationQueue { @@ -117,6 +130,10 @@ size_t outstanding_ = 0; // Operations posted but not completed. bool WorkerPool::PostTask(const tracked_objects::Location& from_here, Task* task, bool task_is_slow) { + if (use_linux_workerpool_) { + return worker_pool_mac::MacPostTaskHelper(from_here, task, task_is_slow); + } + base::mac::ScopedNSAutoreleasePool autorelease_pool; // Ignore |task_is_slow|, it doesn't map directly to any tunable aspect of |