Skip to content

Commit

Permalink
sync: change chan closed(&mut self) -> closed(&self)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaharidichev committed Oct 10, 2020
1 parent 2e05399 commit f6034fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions tokio/src/sync/mpsc/bounded.rs
Expand Up @@ -332,11 +332,11 @@ impl<T> Sender<T> {
///
/// #[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);
/// });
Expand All @@ -351,7 +351,7 @@ impl<T> Sender<T> {
//// println!("Receiver dropped");
/// }
/// ```
pub async fn closed(&mut self) {
pub async fn closed(&self) {
self.chan.closed().await
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/mpsc/chan.rs
Expand Up @@ -147,7 +147,7 @@ impl<T, S: Semaphore> Tx<T, S> {
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;
Expand Down
12 changes: 6 additions & 6 deletions tokio/src/sync/mpsc/unbounded.rs
Expand Up @@ -223,11 +223,11 @@ impl<T> UnboundedSender<T> {
///
/// #[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);
/// });
Expand All @@ -242,7 +242,7 @@ impl<T> UnboundedSender<T> {
//// 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
Expand Down
8 changes: 4 additions & 4 deletions tokio/src/sync/tests/loom_mpsc.rs
Expand Up @@ -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);
});
Expand All @@ -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);
});
Expand Down

0 comments on commit f6034fd

Please sign in to comment.