Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: base/threading/worker_pool_posix_unittest.cc

Issue 10004001: Add virtual and OVERRIDE to base/ implementation files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win Fix -> Missing header Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/threading/worker_pool_posix.cc ('k') | base/time_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 class PosixDynamicThreadPoolTest : public testing::Test { 90 class PosixDynamicThreadPoolTest : public testing::Test {
91 protected: 91 protected:
92 PosixDynamicThreadPoolTest() 92 PosixDynamicThreadPoolTest()
93 : pool_(new base::PosixDynamicThreadPool("dynamic_pool", 60*60)), 93 : pool_(new base::PosixDynamicThreadPool("dynamic_pool", 60*60)),
94 peer_(pool_.get()), 94 peer_(pool_.get()),
95 counter_(0), 95 counter_(0),
96 num_waiting_to_start_(0), 96 num_waiting_to_start_(0),
97 num_waiting_to_start_cv_(&num_waiting_to_start_lock_), 97 num_waiting_to_start_cv_(&num_waiting_to_start_lock_),
98 start_(true, false) {} 98 start_(true, false) {}
99 99
100 virtual void SetUp() { 100 virtual void SetUp() OVERRIDE {
101 peer_.set_num_idle_threads_cv(new ConditionVariable(peer_.lock())); 101 peer_.set_num_idle_threads_cv(new ConditionVariable(peer_.lock()));
102 } 102 }
103 103
104 virtual void TearDown() { 104 virtual void TearDown() OVERRIDE {
105 // Wake up the idle threads so they can terminate. 105 // Wake up the idle threads so they can terminate.
106 if (pool_.get()) pool_->Terminate(); 106 if (pool_.get()) pool_->Terminate();
107 } 107 }
108 108
109 void WaitForTasksToStart(int num_tasks) { 109 void WaitForTasksToStart(int num_tasks) {
110 base::AutoLock num_waiting_to_start_locked(num_waiting_to_start_lock_); 110 base::AutoLock num_waiting_to_start_locked(num_waiting_to_start_lock_);
111 while (num_waiting_to_start_ < num_tasks) { 111 while (num_waiting_to_start_ < num_tasks) {
112 num_waiting_to_start_cv_.Wait(); 112 num_waiting_to_start_cv_.Wait();
113 } 113 }
114 } 114 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « base/threading/worker_pool_posix.cc ('k') | base/time_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698