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.
Trait Implementations
impl<T: Send> Send for Sender<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for Sender<T>
impl<T> !Sync for Sender<T>
impl<T> Unpin for Sender<T>
impl<T> !UnwindSafe for Sender<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more