OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // test both fast and non-flaky. | 61 // test both fast and non-flaky. |
62 // With 1 us wait as the switch, up to 7 rounds have been observed. | 62 // With 1 us wait as the switch, up to 7 rounds have been observed. |
63 while (count->Count() < target && loop_counter < 100 * target) { | 63 while (count->Count() < target && loop_counter < 100 * target) { |
64 ++loop_counter; | 64 ++loop_counter; |
65 SwitchProcess(); | 65 SwitchProcess(); |
66 } | 66 } |
67 return (count->Count() >= target); | 67 return (count->Count() >= target); |
68 } | 68 } |
69 }; | 69 }; |
70 | 70 |
71 bool LockUnlockThenStopRunFunction(void* obj) { | 71 void LockUnlockThenStopRunFunction(void* obj) { |
72 ProtectedCount* the_count = static_cast<ProtectedCount*>(obj); | 72 ProtectedCount* the_count = static_cast<ProtectedCount*>(obj); |
73 the_count->Increment(); | 73 the_count->Increment(); |
74 return false; | |
75 } | 74 } |
76 | 75 |
77 TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS { | 76 TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS { |
78 CriticalSectionWrapper* crit_sect = | 77 CriticalSectionWrapper* crit_sect = |
79 CriticalSectionWrapper::CreateCriticalSection(); | 78 CriticalSectionWrapper::CreateCriticalSection(); |
80 ProtectedCount count(crit_sect); | 79 ProtectedCount count(crit_sect); |
81 rtc::PlatformThread thread( | 80 rtc::PlatformThread thread( |
82 &LockUnlockThenStopRunFunction, &count, "ThreadWakesOnce"); | 81 &LockUnlockThenStopRunFunction, &count, "ThreadWakesOnce"); |
83 crit_sect->Enter(); | 82 crit_sect->Enter(); |
84 thread.Start(); | 83 thread.Start(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 127 |
129 SwitchProcess(); | 128 SwitchProcess(); |
130 EXPECT_TRUE(WaitForCount(count_before + 1, &count)); | 129 EXPECT_TRUE(WaitForCount(count_before + 1, &count)); |
131 thread.Stop(); | 130 thread.Stop(); |
132 delete crit_sect; | 131 delete crit_sect; |
133 } | 132 } |
134 | 133 |
135 } // anonymous namespace | 134 } // anonymous namespace |
136 | 135 |
137 } // namespace webrtc | 136 } // namespace webrtc |
OLD | NEW |