Skip to content

Commit 78614c6

Browse files
author
Stjepan Glavina
authored
Clarify blocking in channel docs (#448)
1 parent ddbbbfc commit 78614c6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/sync/channel.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::sync::WakerSet;
2222
///
2323
/// Senders and receivers can be cloned. When all senders associated with a channel get dropped, it
2424
/// becomes closed. Receive operations on a closed and empty channel return `None` instead of
25-
/// blocking.
25+
/// trying to await a message.
2626
///
2727
/// # Panics
2828
///
@@ -44,7 +44,7 @@ use crate::sync::WakerSet;
4444
/// s.send(1).await;
4545
///
4646
/// task::spawn(async move {
47-
/// // This call blocks the current task because the channel is full.
47+
/// // This call will have to wait because the channel is full.
4848
/// // It will be able to complete only after the first message is received.
4949
/// s.send(2).await;
5050
/// });
@@ -102,8 +102,7 @@ pub struct Sender<T> {
102102
impl<T> Sender<T> {
103103
/// Sends a message into the channel.
104104
///
105-
/// If the channel is full, this method will block the current task until the send operation
106-
/// can proceed.
105+
/// If the channel is full, this method will wait until there is space in the channel.
107106
///
108107
/// # Examples
109108
///
@@ -346,9 +345,8 @@ pub struct Receiver<T> {
346345
impl<T> Receiver<T> {
347346
/// Receives a message from the channel.
348347
///
349-
/// If the channel is empty and it still has senders, this method will block the current task
350-
/// until the receive operation can proceed. If the channel is empty and there are no more
351-
/// senders, this method returns `None`.
348+
/// If the channel is empty and still has senders, this method will wait until a message is
349+
/// sent into the channel or until all senders get dropped.
352350
///
353351
/// # Examples
354352
///

0 commit comments

Comments
 (0)