OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 struct PendingTask { | 49 struct PendingTask { |
50 PendingTask(const tracked_objects::Location& posted_from, | 50 PendingTask(const tracked_objects::Location& posted_from, |
51 const base::Closure& task); | 51 const base::Closure& task); |
52 ~PendingTask(); | 52 ~PendingTask(); |
53 // TODO(ajwong): After we figure out why Mac's ~AtExitManager dies when | 53 // TODO(ajwong): After we figure out why Mac's ~AtExitManager dies when |
54 // destructing the lock, add in extra info so we can call | 54 // destructing the lock, add in extra info so we can call |
55 // tracked_objects::TallyADeathIfActive() and | 55 // tracked_objects::TallyADeathIfActive() and |
56 // tracked_objects::TallyABirthIfActive correctly. | 56 // tracked_objects::TallyABirthIfActive correctly. |
57 | 57 |
| 58 const tracked_objects::Location posted_from; |
| 59 |
58 // The task to run. | 60 // The task to run. |
59 base::Closure task; | 61 base::Closure task; |
60 }; | 62 }; |
61 | 63 |
62 // All worker threads will share the same |name_prefix|. They will exit after | 64 // All worker threads will share the same |name_prefix|. They will exit after |
63 // |idle_seconds_before_exit|. | 65 // |idle_seconds_before_exit|. |
64 PosixDynamicThreadPool(const std::string& name_prefix, | 66 PosixDynamicThreadPool(const std::string& name_prefix, |
65 int idle_seconds_before_exit); | 67 int idle_seconds_before_exit); |
66 ~PosixDynamicThreadPool(); | 68 ~PosixDynamicThreadPool(); |
67 | 69 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Only used for tests to ensure correct thread ordering. It will always be | 108 // Only used for tests to ensure correct thread ordering. It will always be |
107 // NULL in non-test code. | 109 // NULL in non-test code. |
108 scoped_ptr<ConditionVariable> num_idle_threads_cv_; | 110 scoped_ptr<ConditionVariable> num_idle_threads_cv_; |
109 | 111 |
110 DISALLOW_COPY_AND_ASSIGN(PosixDynamicThreadPool); | 112 DISALLOW_COPY_AND_ASSIGN(PosixDynamicThreadPool); |
111 }; | 113 }; |
112 | 114 |
113 } // namespace base | 115 } // namespace base |
114 | 116 |
115 #endif // BASE_THREADING_WORKER_POOL_POSIX_H_ | 117 #endif // BASE_THREADING_WORKER_POOL_POSIX_H_ |
OLD | NEW |