From f6034fd71d74343020ff0d47dab848c35c6be063 Mon Sep 17 00:00:00 2001 From: Zahari Dichev Date: Sat, 10 Oct 2020 11:32:00 +0300 Subject: [PATCH] sync: change chan `closed(&mut self)` -> closed(&self) Refs: #2928 --- tokio/src/sync/mpsc/bounded.rs | 12 ++++++------ tokio/src/sync/mpsc/chan.rs | 2 +- tokio/src/sync/mpsc/unbounded.rs | 12 ++++++------ tokio/src/sync/tests/loom_mpsc.rs | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tokio/src/sync/mpsc/bounded.rs b/tokio/src/sync/mpsc/bounded.rs index 38fb753e5ae..76439a8dda4 100644 --- a/tokio/src/sync/mpsc/bounded.rs +++ b/tokio/src/sync/mpsc/bounded.rs @@ -332,11 +332,11 @@ impl Sender { /// /// #[tokio::main] /// async fn main() { - /// let (mut tx1, rx) = mpsc::channel::<()>(1); - /// let mut tx2 = tx1.clone(); - /// let mut tx3 = tx1.clone(); - /// let mut tx4 = tx1.clone(); - /// let mut tx5 = tx1.clone(); + /// let (tx1, rx) = mpsc::channel::<()>(1); + /// let tx2 = tx1.clone(); + /// let tx3 = tx1.clone(); + /// let tx4 = tx1.clone(); + /// let tx5 = tx1.clone(); /// tokio::spawn(async move { /// drop(rx); /// }); @@ -351,7 +351,7 @@ impl Sender { //// println!("Receiver dropped"); /// } /// ``` - pub async fn closed(&mut self) { + pub async fn closed(&self) { self.chan.closed().await } diff --git a/tokio/src/sync/mpsc/chan.rs b/tokio/src/sync/mpsc/chan.rs index 6fedb5c5f00..3f50493e0ff 100644 --- a/tokio/src/sync/mpsc/chan.rs +++ b/tokio/src/sync/mpsc/chan.rs @@ -147,7 +147,7 @@ impl Tx { self.inner.semaphore.is_closed() } - pub(crate) async fn closed(&mut self) { + pub(crate) async fn closed(&self) { use std::future::Future; use std::pin::Pin; use std::task::Poll; diff --git a/tokio/src/sync/mpsc/unbounded.rs b/tokio/src/sync/mpsc/unbounded.rs index b92cbc05db3..fe882d5b5c0 100644 --- a/tokio/src/sync/mpsc/unbounded.rs +++ b/tokio/src/sync/mpsc/unbounded.rs @@ -223,11 +223,11 @@ impl UnboundedSender { /// /// #[tokio::main] /// async fn main() { - /// let (mut tx1, rx) = mpsc::unbounded_channel::<()>(); - /// let mut tx2 = tx1.clone(); - /// let mut tx3 = tx1.clone(); - /// let mut tx4 = tx1.clone(); - /// let mut tx5 = tx1.clone(); + /// let (tx1, rx) = mpsc::unbounded_channel::<()>(); + /// let tx2 = tx1.clone(); + /// let tx3 = tx1.clone(); + /// let tx4 = tx1.clone(); + /// let tx5 = tx1.clone(); /// tokio::spawn(async move { /// drop(rx); /// }); @@ -242,7 +242,7 @@ impl UnboundedSender { //// println!("Receiver dropped"); /// } /// ``` - pub async fn closed(&mut self) { + pub async fn closed(&self) { self.chan.closed().await } /// Checks if the channel has been closed. This happens when the diff --git a/tokio/src/sync/tests/loom_mpsc.rs b/tokio/src/sync/tests/loom_mpsc.rs index 330e798bcdf..859a1477adb 100644 --- a/tokio/src/sync/tests/loom_mpsc.rs +++ b/tokio/src/sync/tests/loom_mpsc.rs @@ -43,8 +43,8 @@ fn closing_unbounded_tx() { #[test] fn closing_bounded_rx() { loom::model(|| { - let (mut tx1, rx) = mpsc::channel::<()>(16); - let mut tx2 = tx1.clone(); + let (tx1, rx) = mpsc::channel::<()>(16); + let tx2 = tx1.clone(); thread::spawn(move || { drop(rx); }); @@ -57,8 +57,8 @@ fn closing_bounded_rx() { #[test] fn closing_unbounded_rx() { loom::model(|| { - let (mut tx1, rx) = mpsc::unbounded_channel::<()>(); - let mut tx2 = tx1.clone(); + let (tx1, rx) = mpsc::unbounded_channel::<()>(); + let tx2 = tx1.clone(); thread::spawn(move || { drop(rx); });