OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 end_signal_.Set(); | 123 end_signal_.Set(); |
124 } | 124 } |
125 | 125 |
126 virtual void DoRun() = 0; | 126 virtual void DoRun() = 0; |
127 | 127 |
128 RateLimiter* const rate_limiter_; | 128 RateLimiter* const rate_limiter_; |
129 rtc::Event start_signal_; | 129 rtc::Event start_signal_; |
130 rtc::Event end_signal_; | 130 rtc::Event end_signal_; |
131 }; | 131 }; |
132 | 132 |
133 bool RunTask(void* thread_task) { | 133 void RunTask(void* thread_task) { |
134 reinterpret_cast<ThreadTask*>(thread_task)->Run(); | 134 reinterpret_cast<ThreadTask*>(thread_task)->Run(); |
135 return false; | |
136 } | 135 } |
137 | 136 |
138 TEST_F(RateLimitTest, MultiThreadedUsage) { | 137 TEST_F(RateLimitTest, MultiThreadedUsage) { |
139 // Simple sanity test, with different threads calling the various methods. | 138 // Simple sanity test, with different threads calling the various methods. |
140 // Runs a few simple tasks, each on its own thread, but coordinated with | 139 // Runs a few simple tasks, each on its own thread, but coordinated with |
141 // events so that they run in a serialized order. Intended to catch data | 140 // events so that they run in a serialized order. Intended to catch data |
142 // races when run with tsan et al. | 141 // races when run with tsan et al. |
143 | 142 |
144 // Half window size, double rate -> same amount of bytes needed to fill rate. | 143 // Half window size, double rate -> same amount of bytes needed to fill rate. |
145 | 144 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 194 |
196 // All rate consumed. | 195 // All rate consumed. |
197 EXPECT_FALSE(rate_limiter->TryUseRate(1)); | 196 EXPECT_FALSE(rate_limiter->TryUseRate(1)); |
198 | 197 |
199 thread1.Stop(); | 198 thread1.Stop(); |
200 thread2.Stop(); | 199 thread2.Stop(); |
201 thread3.Stop(); | 200 thread3.Stop(); |
202 } | 201 } |
203 | 202 |
204 } // namespace webrtc | 203 } // namespace webrtc |
OLD | NEW |