| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Same as above and accepts an item verification functor. | 99 // Same as above and accepts an item verification functor. |
| 100 SwapQueue(size_t size, | 100 SwapQueue(size_t size, |
| 101 const T& prototype, | 101 const T& prototype, |
| 102 const QueueItemVerifier& queue_item_verifier) | 102 const QueueItemVerifier& queue_item_verifier) |
| 103 : queue_item_verifier_(queue_item_verifier), queue_(size, prototype) { | 103 : queue_item_verifier_(queue_item_verifier), queue_(size, prototype) { |
| 104 RTC_DCHECK(VerifyQueueSlots()); | 104 RTC_DCHECK(VerifyQueueSlots()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 size_t Capacity() const { |
| 108 rtc::CritScope cs(&crit_queue_); |
| 109 return queue_.size(); |
| 110 } |
| 111 |
| 112 size_t Size() const { |
| 113 rtc::CritScope cs(&crit_queue_); |
| 114 return num_elements_; |
| 115 } |
| 116 |
| 107 // Resets the queue to have zero content wile maintaining the queue size. | 117 // Resets the queue to have zero content wile maintaining the queue size. |
| 108 void Clear() { | 118 void Clear() { |
| 109 rtc::CritScope cs(&crit_queue_); | 119 rtc::CritScope cs(&crit_queue_); |
| 110 next_write_index_ = 0; | 120 next_write_index_ = 0; |
| 111 next_read_index_ = 0; | 121 next_read_index_ = 0; |
| 112 num_elements_ = 0; | 122 num_elements_ = 0; |
| 113 } | 123 } |
| 114 | 124 |
| 115 // Inserts a "full" T at the back of the queue by swapping *input with an | 125 // Inserts a "full" T at the back of the queue by swapping *input with an |
| 116 // "empty" T from the queue. | 126 // "empty" T from the queue. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 212 |
| 203 // queue_.size() is constant. | 213 // queue_.size() is constant. |
| 204 std::vector<T> queue_ GUARDED_BY(crit_queue_); | 214 std::vector<T> queue_ GUARDED_BY(crit_queue_); |
| 205 | 215 |
| 206 RTC_DISALLOW_COPY_AND_ASSIGN(SwapQueue); | 216 RTC_DISALLOW_COPY_AND_ASSIGN(SwapQueue); |
| 207 }; | 217 }; |
| 208 | 218 |
| 209 } // namespace webrtc | 219 } // namespace webrtc |
| 210 | 220 |
| 211 #endif // WEBRTC_BASE_SWAP_QUEUE_H_ | 221 #endif // WEBRTC_BASE_SWAP_QUEUE_H_ |
| OLD | NEW |