| 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 // The thread pool used in the POSIX implementation of WorkerPool dynamically | 5 // The thread pool used in the POSIX implementation of WorkerPool dynamically |
| 6 // adds threads as necessary to handle all tasks. It keeps old threads around | 6 // adds threads as necessary to handle all tasks. It keeps old threads around |
| 7 // for a period of time to allow them to be reused. After this waiting period, | 7 // for a period of time to allow them to be reused. After this waiting period, |
| 8 // the threads exit. This thread pool uses non-joinable threads, therefore | 8 // the threads exit. This thread pool uses non-joinable threads, therefore |
| 9 // worker threads are not joined during process shutdown. This means that | 9 // worker threads are not joined during process shutdown. This means that |
| 10 // potentially long running tasks (such as DNS lookup) do not block process | 10 // potentially long running tasks (such as DNS lookup) do not block process |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "base/callback_forward.h" | 31 #include "base/callback_forward.h" |
| 32 #include "base/location.h" | 32 #include "base/location.h" |
| 33 #include "base/macros.h" | 33 #include "base/macros.h" |
| 34 #include "base/memory/ref_counted.h" | 34 #include "base/memory/ref_counted.h" |
| 35 #include "base/pending_task.h" | 35 #include "base/pending_task.h" |
| 36 #include "base/synchronization/condition_variable.h" | 36 #include "base/synchronization/condition_variable.h" |
| 37 #include "base/synchronization/lock.h" | 37 #include "base/synchronization/lock.h" |
| 38 #include "base/threading/platform_thread.h" | 38 #include "base/threading/platform_thread.h" |
| 39 #include "base/tracked_objects.h" | 39 #include "base/tracked_objects.h" |
| 40 | 40 |
| 41 class Task; | |
| 42 | |
| 43 namespace base { | 41 namespace base { |
| 44 | 42 |
| 45 class BASE_EXPORT PosixDynamicThreadPool | 43 class BASE_EXPORT PosixDynamicThreadPool |
| 46 : public RefCountedThreadSafe<PosixDynamicThreadPool> { | 44 : public RefCountedThreadSafe<PosixDynamicThreadPool> { |
| 47 public: | 45 public: |
| 48 class PosixDynamicThreadPoolPeer; | 46 class PosixDynamicThreadPoolPeer; |
| 49 | 47 |
| 50 // All worker threads will share the same |name_prefix|. They will exit after | 48 // All worker threads will share the same |name_prefix|. They will exit after |
| 51 // |idle_seconds_before_exit|. | 49 // |idle_seconds_before_exit|. |
| 52 PosixDynamicThreadPool(const std::string& name_prefix, | 50 PosixDynamicThreadPool(const std::string& name_prefix, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // Only used for tests to ensure correct thread ordering. It will always be | 87 // Only used for tests to ensure correct thread ordering. It will always be |
| 90 // NULL in non-test code. | 88 // NULL in non-test code. |
| 91 std::unique_ptr<ConditionVariable> num_idle_threads_cv_; | 89 std::unique_ptr<ConditionVariable> num_idle_threads_cv_; |
| 92 | 90 |
| 93 DISALLOW_COPY_AND_ASSIGN(PosixDynamicThreadPool); | 91 DISALLOW_COPY_AND_ASSIGN(PosixDynamicThreadPool); |
| 94 }; | 92 }; |
| 95 | 93 |
| 96 } // namespace base | 94 } // namespace base |
| 97 | 95 |
| 98 #endif // BASE_THREADING_WORKER_POOL_POSIX_H_ | 96 #endif // BASE_THREADING_WORKER_POOL_POSIX_H_ |
| OLD | NEW |