OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 static int AtomicOp(int* i) { return AtomicOps::Decrement(i); } | 194 static int AtomicOp(int* i) { return AtomicOps::Decrement(i); } |
195 }; | 195 }; |
196 | 196 |
197 struct CompareAndSwapOp { | 197 struct CompareAndSwapOp { |
198 static int AtomicOp(int* i) { return AtomicOps::CompareAndSwap(i, 0, 1); } | 198 static int AtomicOp(int* i) { return AtomicOps::CompareAndSwap(i, 0, 1); } |
199 }; | 199 }; |
200 | 200 |
201 void StartThreads(std::vector<std::unique_ptr<Thread>>* threads, | 201 void StartThreads(std::vector<std::unique_ptr<Thread>>* threads, |
202 MessageHandler* handler) { | 202 MessageHandler* handler) { |
203 for (int i = 0; i < kNumThreads; ++i) { | 203 for (int i = 0; i < kNumThreads; ++i) { |
204 std::unique_ptr<Thread> thread(Thread::Create()); | 204 std::unique_ptr<Thread> thread(new Thread()); |
205 thread->Start(); | 205 thread->Start(); |
206 thread->Post(RTC_FROM_HERE, handler); | 206 thread->Post(RTC_FROM_HERE, handler); |
207 threads->push_back(std::move(thread)); | 207 threads->push_back(std::move(thread)); |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 } // namespace | 211 } // namespace |
212 | 212 |
213 TEST(AtomicOpsTest, Simple) { | 213 TEST(AtomicOpsTest, Simple) { |
214 int value = 0; | 214 int value = 0; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 for (auto& t : threads) | 404 for (auto& t : threads) |
405 t.Start(&test_data, kThreadRepeats, 1); | 405 t.Start(&test_data, kThreadRepeats, 1); |
406 | 406 |
407 event.Wait(Event::kForever); | 407 event.Wait(Event::kForever); |
408 | 408 |
409 for (auto& t : threads) | 409 for (auto& t : threads) |
410 t.Stop(); | 410 t.Stop(); |
411 } | 411 } |
412 | 412 |
413 } // namespace rtc | 413 } // namespace rtc |
OLD | NEW |