summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/tests/loom_broadcast.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-10-21 15:14:52 -0700
committerGitHub <noreply@github.com>2020-10-21 15:14:52 -0700
commit8bfb1c92ceadd04f847d98ed482e7e59a3074954 (patch)
treeb51d60b42131dd5f6b4b6a4c2212052620e6f542 /tokio/src/sync/tests/loom_broadcast.rs
parentb48fec96551ac95768b76102703c4039a64c1168 (diff)
sync: revert Clone impl for broadcast::Receiver (#3020)
The `Receiver` handle maintains a position in the broadcast channel for itself. Cloning implies copying the state of the value. Intuitively, cloning a `broadcast::Receiver` would return a new receiver with an identical position. However, the current implementation returns a new `Receiver` positioned at the tail of the channel. This behavior subtlety is why `new_subscriber()` is used to create `Receiver` handles. An alternate API should consider the position issue. Refs: #2933
Diffstat (limited to 'tokio/src/sync/tests/loom_broadcast.rs')
-rw-r--r--tokio/src/sync/tests/loom_broadcast.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/tokio/src/sync/tests/loom_broadcast.rs b/tokio/src/sync/tests/loom_broadcast.rs
index e15dc25f..4b1f034f 100644
--- a/tokio/src/sync/tests/loom_broadcast.rs
+++ b/tokio/src/sync/tests/loom_broadcast.rs
@@ -92,12 +92,11 @@ fn broadcast_two() {
});
}
-// Exercise the Receiver Clone impl as well
#[test]
fn broadcast_wrap() {
loom::model(|| {
let (tx, mut rx1) = broadcast::channel(2);
- let mut rx2 = rx1.clone();
+ let mut rx2 = tx.subscribe();
let th1 = thread::spawn(move || {
block_on(async {