summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/tests/loom_mpsc.rs
diff options
context:
space:
mode:
authorZahari Dichev <zaharidichev@gmail.com>2020-09-25 18:40:31 +0300
committerGitHub <noreply@github.com>2020-09-25 08:40:31 -0700
commit55d932a21fd4c5fa298ca3cfdcb1388dbbf43dd0 (patch)
tree500d0d68a991277b466eabb5b87379bb1037d093 /tokio/src/sync/tests/loom_mpsc.rs
parent444660664b96f758610a0e7201a6a1a31a0f2405 (diff)
sync: add `mpsc::Sender::closed` future (#2840)
Adding closed future, makes it possible to select over closed and some other work, so that the task is woken when the channel is closed and can proactively cancel itself. Added a mpsc::Sender::closed future that will become ready when the receiver is closed.
Diffstat (limited to 'tokio/src/sync/tests/loom_mpsc.rs')
-rw-r--r--tokio/src/sync/tests/loom_mpsc.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tokio/src/sync/tests/loom_mpsc.rs b/tokio/src/sync/tests/loom_mpsc.rs
index e8db2dea..330e798b 100644
--- a/tokio/src/sync/tests/loom_mpsc.rs
+++ b/tokio/src/sync/tests/loom_mpsc.rs
@@ -41,6 +41,34 @@ fn closing_unbounded_tx() {
}
#[test]
+fn closing_bounded_rx() {
+ loom::model(|| {
+ let (mut tx1, rx) = mpsc::channel::<()>(16);
+ let mut tx2 = tx1.clone();
+ thread::spawn(move || {
+ drop(rx);
+ });
+
+ block_on(tx1.closed());
+ block_on(tx2.closed());
+ });
+}
+
+#[test]
+fn closing_unbounded_rx() {
+ loom::model(|| {
+ let (mut tx1, rx) = mpsc::unbounded_channel::<()>();
+ let mut tx2 = tx1.clone();
+ thread::spawn(move || {
+ drop(rx);
+ });
+
+ block_on(tx1.closed());
+ block_on(tx2.closed());
+ });
+}
+
+#[test]
fn dropping_tx() {
loom::model(|| {
let (tx, mut rx) = mpsc::channel::<()>(16);