pub fn send(self, message: T) -> Result<(), SendError<T>> {
        // SAFETY: The channel exists on the heap for the entire duration of this method.
        let channel: &mut Channel<T> = unsafe { &mut *self.channel_ptr };

        // Don't run our Drop implementation if send was called, any cleanup now happens here
        mem::forget(self);

        // Write the message into the channel on the heap.
        channel.write_message(message);
        // Set the state to signal there is a message on the channel.
        match channel.state.swap(MESSAGE, SeqCst) {
            // The receiver is alive and has not started waiting. Send done.
            EMPTY => Ok(()),
            // The receiver is waiting. Wake it up so it can return the message.
            RECEIVING => {
                unsafe { channel.take_waker() }.unpark();
                Ok(())
            }
            // The receiver was already dropped. The error is responsible for freeing the channel.
            DISCONNECTED => Err(SendError::new(channel)),
            _ => unreachable!(),
        }
    }
/// 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 completely 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 currently
/// involves a mutex in Rust's standard library. 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, which might or
/// might not be lock-free.
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 completely 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 currently
involves a mutex in Rust's standard library. 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, which might or
might not be lock-free.
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 completely 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 currently involves a mutex in Rust ' s standard library . 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 which might or might not be lock - free .
pub fn send(self, message: T) -> Result<(), SendError<T>> {
        // SAFETY: The channel exists on the heap for the entire duration of this method.
        let channel: &mut Channel<T> = unsafe { &mut *self.channel_ptr };
        // Don't run our Drop implementation if send was called, any cleanup now happens here
        mem::forget(self);
        // Write the message into the channel on the heap.
        channel.write_message(message);
        // Set the state to signal there is a message on the channel.
        match channel.state.swap(MESSAGE, SeqCst) {
            // The receiver is alive and has not started waiting. Send done.
            EMPTY => Ok(()),
            // The receiver is waiting. Wake it up so it can return the message.
            RECEIVING => {
                unsafe { channel.take_waker() }.unpark();
                Ok(())
            }
            // The receiver was already dropped. The error is responsible for freeing the channel.
            DISCONNECTED => Err(SendError::new(channel)),
            _ => unreachable!(),
        }
    }
pub fn send ( self , message : T ) -> Result < ( ) , SendError < T > > { // SAFETY: The channel exists on the heap for the entire duration of this method. let channel : & mut Channel < T > = unsafe { & mut * self . channel_ptr } ; // Don't run our Drop implementation if send was called, any cleanup now happens here mem :: forget ( self ) ; // Write the message into the channel on the heap. channel . write_message ( message ) ; // Set the state to signal there is a message on the channel. match channel . state . swap ( MESSAGE , SeqCst ) { // The receiver is alive and has not started waiting. Send done. EMPTY => Ok ( ( ) ) , // The receiver is waiting. Wake it up so it can return the message. RECEIVING => { unsafe { channel . take_waker ( ) } . unpark ( ) ; Ok ( ( ) ) } // The receiver was already dropped. The error is responsible for freeing the channel. DISCONNECTED => Err ( SendError :: new ( channel ) ) , _ => unreachable ! ( ) , } }
Sends `message` over the channel to the corresponding [`Receiver`].
Sends ` message ` over the channel to the corresponding [ ` Receiver ` ] .
self
message
T
self
message
T