| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 struct CompareAndSwapOp { | 198 struct CompareAndSwapOp { |
| 199 static int AtomicOp(int* i) { return AtomicOps::CompareAndSwap(i, 0, 1); } | 199 static int AtomicOp(int* i) { return AtomicOps::CompareAndSwap(i, 0, 1); } |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 void StartThreads(ScopedPtrCollection<Thread>* threads, | 202 void StartThreads(ScopedPtrCollection<Thread>* threads, |
| 203 MessageHandler* handler) { | 203 MessageHandler* handler) { |
| 204 for (int i = 0; i < kNumThreads; ++i) { | 204 for (int i = 0; i < kNumThreads; ++i) { |
| 205 Thread* thread = new Thread(); | 205 Thread* thread = new Thread(); |
| 206 thread->Start(); | 206 thread->Start(); |
| 207 thread->Post(handler); | 207 thread->Post(RTC_FROM_HERE, handler); |
| 208 threads->PushBack(thread); | 208 threads->PushBack(thread); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace | 212 } // namespace |
| 213 | 213 |
| 214 TEST(AtomicOpsTest, Simple) { | 214 TEST(AtomicOpsTest, Simple) { |
| 215 int value = 0; | 215 int value = 0; |
| 216 EXPECT_EQ(1, AtomicOps::Increment(&value)); | 216 EXPECT_EQ(1, AtomicOps::Increment(&value)); |
| 217 EXPECT_EQ(1, value); | 217 EXPECT_EQ(1, value); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 for (auto& t : threads) | 422 for (auto& t : threads) |
| 423 t.Start(&test_data, kThreadRepeats, 1); | 423 t.Start(&test_data, kThreadRepeats, 1); |
| 424 | 424 |
| 425 event.Wait(Event::kForever); | 425 event.Wait(Event::kForever); |
| 426 | 426 |
| 427 for (auto& t : threads) | 427 for (auto& t : threads) |
| 428 t.Stop(); | 428 t.Stop(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 } // namespace rtc | 431 } // namespace rtc |
| OLD | NEW |