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

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

Issue 8221021: Modify WaitableEvent::Wait() to return void (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comment and style Created 9 years, 2 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/synchronization/waitable_event_win.cc ('k') | base/threading/worker_pool_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) 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 #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/synchronization/condition_variable.h" 9 #include "base/synchronization/condition_variable.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 num_waiting_to_start_(num_waiting_to_start), 99 num_waiting_to_start_(num_waiting_to_start),
100 num_waiting_to_start_cv_(num_waiting_to_start_cv), 100 num_waiting_to_start_cv_(num_waiting_to_start_cv),
101 start_(start) {} 101 start_(start) {}
102 102
103 virtual void Run() { 103 virtual void Run() {
104 { 104 {
105 base::AutoLock num_waiting_to_start_locked(*num_waiting_to_start_lock_); 105 base::AutoLock num_waiting_to_start_locked(*num_waiting_to_start_lock_);
106 (*num_waiting_to_start_)++; 106 (*num_waiting_to_start_)++;
107 } 107 }
108 num_waiting_to_start_cv_->Signal(); 108 num_waiting_to_start_cv_->Signal();
109 CHECK(start_->Wait()); 109 start_->Wait();
110 incrementer_.Run(); 110 incrementer_.Run();
111 } 111 }
112 112
113 private: 113 private:
114 IncrementingTask incrementer_; 114 IncrementingTask incrementer_;
115 Lock* num_waiting_to_start_lock_; 115 Lock* num_waiting_to_start_lock_;
116 int* num_waiting_to_start_; 116 int* num_waiting_to_start_;
117 ConditionVariable* num_waiting_to_start_cv_; 117 ConditionVariable* num_waiting_to_start_cv_;
118 base::WaitableEvent* start_; 118 base::WaitableEvent* start_;
119 119
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Add another non blocking task. There are no threads to reuse. 261 // Add another non blocking task. There are no threads to reuse.
262 pool_->PostTask(FROM_HERE, CreateNewIncrementingTask()); 262 pool_->PostTask(FROM_HERE, CreateNewIncrementingTask());
263 WaitForIdleThreads(1); 263 WaitForIdleThreads(1);
264 264
265 EXPECT_EQ(3U, unique_threads_.size()); 265 EXPECT_EQ(3U, unique_threads_.size());
266 EXPECT_EQ(1, peer_.num_idle_threads()); 266 EXPECT_EQ(1, peer_.num_idle_threads());
267 EXPECT_EQ(4, counter_); 267 EXPECT_EQ(4, counter_);
268 } 268 }
269 269
270 } // namespace base 270 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_win.cc ('k') | base/threading/worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698