mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
sync: clarify that recv returns None once closed and no more messages (#7920)
The previous documentation stated: 'As such, Receiver::poll returns Ok(Ready(None))' This was misleading: when all Sender handles are dropped, recv does NOT immediately return None. Buffered messages already in the channel can still be received. Only after all senders are dropped AND the channel has been fully drained does recv return None. Also update the method reference from the internal Receiver::poll to the public API: Receiver::recv and Receiver::poll_recv. Closes #6053
This commit is contained in:
@@ -29,7 +29,9 @@
|
||||
//!
|
||||
//! When all [`Sender`] handles have been dropped, it is no longer
|
||||
//! possible to send values into the channel. This is considered the termination
|
||||
//! event of the stream. As such, `Receiver::poll` returns `Ok(Ready(None))`.
|
||||
//! event of the stream. Once all senders have been dropped and any remaining
|
||||
//! buffered values have been received, `Receiver::recv` returns `None`
|
||||
//! (and `Receiver::poll_recv` returns `Poll::Ready(None)`).
|
||||
//!
|
||||
//! If the [`Receiver`] handle is dropped, then messages can no longer
|
||||
//! be read out of the channel. In this case, all further attempts to send will
|
||||
|
||||
Reference in New Issue
Block a user