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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 class PosixDynamicThreadPoolTest : public testing::Test { | 91 class PosixDynamicThreadPoolTest : public testing::Test { |
92 protected: | 92 protected: |
93 PosixDynamicThreadPoolTest() | 93 PosixDynamicThreadPoolTest() |
94 : pool_(new base::PosixDynamicThreadPool("dynamic_pool", 60 * 60)), | 94 : pool_(new base::PosixDynamicThreadPool("dynamic_pool", 60 * 60)), |
95 peer_(pool_.get()), | 95 peer_(pool_.get()), |
96 counter_(0), | 96 counter_(0), |
97 num_waiting_to_start_(0), | 97 num_waiting_to_start_(0), |
98 num_waiting_to_start_cv_(&num_waiting_to_start_lock_), | 98 num_waiting_to_start_cv_(&num_waiting_to_start_lock_), |
99 start_(true, false) {} | 99 start_(WaitableEvent::ResetPolicy::MANUAL, |
| 100 WaitableEvent::InitialState::NOT_SIGNALED) {} |
100 | 101 |
101 void SetUp() override { | 102 void SetUp() override { |
102 peer_.set_num_idle_threads_cv(new ConditionVariable(peer_.lock())); | 103 peer_.set_num_idle_threads_cv(new ConditionVariable(peer_.lock())); |
103 } | 104 } |
104 | 105 |
105 void TearDown() override { | 106 void TearDown() override { |
106 // Wake up the idle threads so they can terminate. | 107 // Wake up the idle threads so they can terminate. |
107 if (pool_.get()) | 108 if (pool_.get()) |
108 pool_->Terminate(); | 109 pool_->Terminate(); |
109 } | 110 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // joined, the next-created thread can get a re-used ID if the allocation of | 247 // joined, the next-created thread can get a re-used ID if the allocation of |
247 // the pthread_t structure is taken from the free list. Therefore, there can | 248 // the pthread_t structure is taken from the free list. Therefore, there can |
248 // be either 2 or 3 unique thread IDs in the set at this stage in the test. | 249 // be either 2 or 3 unique thread IDs in the set at this stage in the test. |
249 EXPECT_TRUE(unique_threads_.size() >= 2 && unique_threads_.size() <= 3) | 250 EXPECT_TRUE(unique_threads_.size() >= 2 && unique_threads_.size() <= 3) |
250 << "unique_threads_.size() = " << unique_threads_.size(); | 251 << "unique_threads_.size() = " << unique_threads_.size(); |
251 EXPECT_EQ(1, peer_.num_idle_threads()); | 252 EXPECT_EQ(1, peer_.num_idle_threads()); |
252 EXPECT_EQ(4, counter_); | 253 EXPECT_EQ(4, counter_); |
253 } | 254 } |
254 | 255 |
255 } // namespace base | 256 } // namespace base |
OLD | NEW |