OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/atomic_sequence_num.h" | 5 #include "base/atomic_sequence_num.h" |
6 #include "base/lock.h" | |
7 #include "base/simple_thread.h" | 6 #include "base/simple_thread.h" |
8 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
9 #include "base/waitable_event.h" | 8 #include "base/waitable_event.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
11 | 10 |
12 namespace { | 11 namespace { |
13 | 12 |
14 class SetIntRunner : public base::DelegateSimpleThread::Delegate { | 13 class SetIntRunner : public base::DelegateSimpleThread::Delegate { |
15 public: | 14 public: |
16 SetIntRunner(int* ptr, int val) : ptr_(ptr), val_(val) { } | 15 SetIntRunner(int* ptr, int val) : ptr_(ptr), val_(val) { } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 base::WaitableEvent event(true, false); | 157 base::WaitableEvent event(true, false); |
159 // Changing 9 to 10, for example, would cause us JoinAll() to never return. | 158 // Changing 9 to 10, for example, would cause us JoinAll() to never return. |
160 VerifyPoolRunner verifier(&seq2, 9, &event); | 159 VerifyPoolRunner verifier(&seq2, 9, &event); |
161 pool.Start(); | 160 pool.Start(); |
162 | 161 |
163 pool.AddWork(&verifier, 10); | 162 pool.AddWork(&verifier, 10); |
164 | 163 |
165 pool.JoinAll(); | 164 pool.JoinAll(); |
166 EXPECT_EQ(seq2.GetNext(), 10); | 165 EXPECT_EQ(seq2.GetNext(), 10); |
167 } | 166 } |
OLD | NEW |