-
Notifications
You must be signed in to change notification settings - Fork 671
Open
Description
In the code below that I copied from the latest version, if start_send requires calling poll_ready, doesn't it logically follow that directly calling try_send would also require calling poll_ready since the former trivially calls the latter? This was undocumented: I just happened to look at the implementation for these to determine which I should call (which also isn't clear).
impl<T> Sender<T> {
/// Attempts to send a message on this `Sender`, returning the message
/// if there was an error.
pub fn try_send(&mut self, msg: T) -> Result<(), TrySendError<T>> {
if let Some(inner) = &mut self.0 {
inner.try_send(msg)
} else {
Err(TrySendError { err: SendError { kind: SendErrorKind::Disconnected }, val: msg })
}
}
/// Send a message on the channel.
///
/// This function should only be called after
/// [`poll_ready`](Sender::poll_ready) has reported that the channel is
/// ready to receive a message.
pub fn start_send(&mut self, msg: T) -> Result<(), SendError> {
self.try_send(msg).map_err(|e| e.err)
}
// truncated here for readability
}Metadata
Metadata
Assignees
Labels
No labels