pub struct Sender<T> { /* private fields */ }
Implementations
sourceimpl<T> Sender<T>
impl<T> Sender<T>
sourcepub fn send(self, message: T) -> Result<(), SendError<T>>
pub fn send(self, message: T) -> Result<(), SendError<T>>
Sends message
over the channel to the corresponding Receiver
.
Returns an error if the receiver has already been dropped. The message can be extracted from the error.
This method is lock-free and wait-free when sending on a channel that the
receiver is currently not receiving on. If the receiver is receiving during the send
operation this method includes waking up the thread/task. Unparking a thread involves
a mutex in Rust’s standard library at the time of writing this.
How lock-free waking up an async task is
depends on your executor. If this method returns a SendError
, please mind that dropping
the error involves running any drop implementation on the message type, and freeing the
channel’s heap allocation, which might or might not be lock-free.