OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 next_read_index_ = 0; | 111 next_read_index_ = 0; |
112 num_elements_ = 0; | 112 num_elements_ = 0; |
113 } | 113 } |
114 | 114 |
115 // Inserts a "full" T at the back of the queue by swapping *input with an | 115 // Inserts a "full" T at the back of the queue by swapping *input with an |
116 // "empty" T from the queue. | 116 // "empty" T from the queue. |
117 // Returns true if the item was inserted or false if not (the queue was full). | 117 // Returns true if the item was inserted or false if not (the queue was full). |
118 // When specified, the T given in *input must pass the ItemVerifier() test. | 118 // When specified, the T given in *input must pass the ItemVerifier() test. |
119 // The contents of *input after the call are then also guaranteed to pass the | 119 // The contents of *input after the call are then also guaranteed to pass the |
120 // ItemVerifier() test. | 120 // ItemVerifier() test. |
121 bool Insert(T* input) WARN_UNUSED_RESULT { | 121 bool Insert(T* input) RTC_WARN_UNUSED_RESULT { |
122 RTC_DCHECK(input); | 122 RTC_DCHECK(input); |
123 | 123 |
124 rtc::CritScope cs(&crit_queue_); | 124 rtc::CritScope cs(&crit_queue_); |
125 | 125 |
126 RTC_DCHECK(queue_item_verifier_(*input)); | 126 RTC_DCHECK(queue_item_verifier_(*input)); |
127 | 127 |
128 if (num_elements_ == queue_.size()) { | 128 if (num_elements_ == queue_.size()) { |
129 return false; | 129 return false; |
130 } | 130 } |
131 | 131 |
(...skipping 12 matching lines...) Expand all Loading... |
144 | 144 |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 // Removes the frontmost "full" T from the queue by swapping it with | 148 // Removes the frontmost "full" T from the queue by swapping it with |
149 // the "empty" T in *output. | 149 // the "empty" T in *output. |
150 // Returns true if an item could be removed or false if not (the queue was | 150 // Returns true if an item could be removed or false if not (the queue was |
151 // empty). When specified, The T given in *output must pass the ItemVerifier() | 151 // empty). When specified, The T given in *output must pass the ItemVerifier() |
152 // test and the contents of *output after the call are then also guaranteed to | 152 // test and the contents of *output after the call are then also guaranteed to |
153 // pass the ItemVerifier() test. | 153 // pass the ItemVerifier() test. |
154 bool Remove(T* output) WARN_UNUSED_RESULT { | 154 bool Remove(T* output) RTC_WARN_UNUSED_RESULT { |
155 RTC_DCHECK(output); | 155 RTC_DCHECK(output); |
156 | 156 |
157 rtc::CritScope cs(&crit_queue_); | 157 rtc::CritScope cs(&crit_queue_); |
158 | 158 |
159 RTC_DCHECK(queue_item_verifier_(*output)); | 159 RTC_DCHECK(queue_item_verifier_(*output)); |
160 | 160 |
161 if (num_elements_ == 0) { | 161 if (num_elements_ == 0) { |
162 return false; | 162 return false; |
163 } | 163 } |
164 | 164 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 // queue_.size() is constant. | 203 // queue_.size() is constant. |
204 std::vector<T> queue_ GUARDED_BY(crit_queue_); | 204 std::vector<T> queue_ GUARDED_BY(crit_queue_); |
205 | 205 |
206 RTC_DISALLOW_COPY_AND_ASSIGN(SwapQueue); | 206 RTC_DISALLOW_COPY_AND_ASSIGN(SwapQueue); |
207 }; | 207 }; |
208 | 208 |
209 } // namespace webrtc | 209 } // namespace webrtc |
210 | 210 |
211 #endif // WEBRTC_BASE_SWAP_QUEUE_H_ | 211 #endif // WEBRTC_BASE_SWAP_QUEUE_H_ |
OLD | NEW |