| 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" |
| 11 #include "base/synchronization/condition_variable.h" | 11 #include "base/synchronization/condition_variable.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/googletest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 | 18 |
| 19 // Peer class to provide passthrough access to PosixDynamicThreadPool internals. | 19 // Peer class to provide passthrough access to PosixDynamicThreadPool internals. |
| 20 class PosixDynamicThreadPool::PosixDynamicThreadPoolPeer { | 20 class PosixDynamicThreadPool::PosixDynamicThreadPoolPeer { |
| 21 public: | 21 public: |
| 22 explicit PosixDynamicThreadPoolPeer(PosixDynamicThreadPool* pool) | 22 explicit PosixDynamicThreadPoolPeer(PosixDynamicThreadPool* pool) |
| 23 : pool_(pool) {} | 23 : pool_(pool) {} |
| 24 | 24 |
| 25 Lock* lock() { return &pool_->lock_; } | 25 Lock* lock() { return &pool_->lock_; } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // joined, the next-created thread can get a re-used ID if the allocation of | 245 // joined, the next-created thread can get a re-used ID if the allocation of |
| 246 // the pthread_t structure is taken from the free list. Therefore, there can | 246 // the pthread_t structure is taken from the free list. Therefore, there can |
| 247 // be either 2 or 3 unique thread IDs in the set at this stage in the test. | 247 // be either 2 or 3 unique thread IDs in the set at this stage in the test. |
| 248 EXPECT_TRUE(unique_threads_.size() >= 2 && unique_threads_.size() <= 3) | 248 EXPECT_TRUE(unique_threads_.size() >= 2 && unique_threads_.size() <= 3) |
| 249 << "unique_threads_.size() = " << unique_threads_.size(); | 249 << "unique_threads_.size() = " << unique_threads_.size(); |
| 250 EXPECT_EQ(1, peer_.num_idle_threads()); | 250 EXPECT_EQ(1, peer_.num_idle_threads()); |
| 251 EXPECT_EQ(4, counter_); | 251 EXPECT_EQ(4, counter_); |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // namespace base | 254 } // namespace base |
| OLD | NEW |