Reland "Introduce ability to test echo in PC level test framework"
This is a reland of 77acb015b6ba886da3e7adb9c2106cf873fa8497
Original change's description:
> Introduce ability to test echo in PC level test framework
>
> Bug: webrtc:10138
> Change-Id: Ie638eaec5a46e37dc0eb52e9432fdebd0e4a1c4d
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147866
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28892}
Bug: webrtc:10138
Change-Id: I0358239500ffadbdbae8090bf39535386fbfd40c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149805
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28917}
diff --git a/rtc_base/swap_queue.h b/rtc_base/swap_queue.h
index 8914548..eb0b1ff 100644
--- a/rtc_base/swap_queue.h
+++ b/rtc_base/swap_queue.h
@@ -200,6 +200,16 @@
return true;
}
+ // Returns the current number of elements in the queue. Since elements may be
+ // concurrently added to the queue, the caller must treat this as a lower
+ // bound, not an exact count.
+ // May only be called by the consumer.
+ size_t SizeAtLeast() const {
+ // Acquire memory ordering ensures that we wait for the producer to finish
+ // inserting any element in progress.
+ return std::atomic_load_explicit(&num_elements_, std::memory_order_acquire);
+ }
+
private:
// Verify that the queue slots complies with the ItemVerifier test. This
// function is not thread-safe and can only be used in the constructors.