| OLD | NEW |
| 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/worker_pool_posix.h" | 5 #include "base/threading/worker_pool_posix.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
| 16 #include "base/threading/worker_pool.h" | 16 #include "base/threading/worker_pool.h" |
| 17 #include "base/tracked_objects.h" | 17 #include "base/tracked_objects.h" |
| 18 | 18 |
| 19 using tracked_objects::TrackedTime; | 19 using tracked_objects::TrackedTime; |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 base::LazyInstance<ThreadLocalBoolean>::Leaky | 25 base::LazyInstance<ThreadLocalBoolean>::Leaky |
| 26 g_worker_pool_running_on_this_thread = LAZY_INSTANCE_INITIALIZER; | 26 g_worker_pool_running_on_this_thread = LAZY_INSTANCE_INITIALIZER; |
| 27 | 27 |
| 28 const int kIdleSecondsBeforeExit = 10 * 60; | 28 const int kIdleSecondsBeforeExit = 10 * 60; |
| 29 |
| 30 #ifdef ADDRESS_SANITIZER |
| 31 const int kWorkerThreadStackSize = 256 * 1024; |
| 32 #else |
| 29 // A stack size of 64 KB is too small for the CERT_PKIXVerifyCert | 33 // A stack size of 64 KB is too small for the CERT_PKIXVerifyCert |
| 30 // function of NSS because of NSS bug 439169. | 34 // function of NSS because of NSS bug 439169. |
| 31 const int kWorkerThreadStackSize = 128 * 1024; | 35 const int kWorkerThreadStackSize = 128 * 1024; |
| 36 #endif |
| 32 | 37 |
| 33 class WorkerPoolImpl { | 38 class WorkerPoolImpl { |
| 34 public: | 39 public: |
| 35 WorkerPoolImpl(); | 40 WorkerPoolImpl(); |
| 36 ~WorkerPoolImpl(); | 41 ~WorkerPoolImpl(); |
| 37 | 42 |
| 38 void PostTask(const tracked_objects::Location& from_here, | 43 void PostTask(const tracked_objects::Location& from_here, |
| 39 const base::Closure& task, bool task_is_slow); | 44 const base::Closure& task, bool task_is_slow); |
| 40 | 45 |
| 41 private: | 46 private: |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return PendingTask(FROM_HERE, base::Closure()); | 195 return PendingTask(FROM_HERE, base::Closure()); |
| 191 } | 196 } |
| 192 } | 197 } |
| 193 | 198 |
| 194 PendingTask pending_task = pending_tasks_.front(); | 199 PendingTask pending_task = pending_tasks_.front(); |
| 195 pending_tasks_.pop(); | 200 pending_tasks_.pop(); |
| 196 return pending_task; | 201 return pending_task; |
| 197 } | 202 } |
| 198 | 203 |
| 199 } // namespace base | 204 } // namespace base |
| OLD | NEW |