pub fn recv(&self) -> Option<T> {
        let token = &mut Token::default();
        let oper = Operation::hook(token);
        loop {
            // Try receiving a message several times.
            let backoff = &mut Backoff::new();
            loop {
                if self.start_recv(token, backoff) {
                    unsafe {
                        return self.read(token);
                    }
                }
                if !backoff.step() {
                    break;
                }
            }

            // Prepare for blocking until a sender wakes us up.
            context::with_current(|cx| {
                cx.reset();
                self.receivers.register(oper, cx);

                // Has the channel become ready just now?
                if !self.is_empty() || self.is_closed() {
                    let _ = cx.try_select(Select::Aborted);
                }

                // Block the current thread.
                let sel = cx.wait_until(None);

                match sel {
                    Select::Waiting => unreachable!(),
                    Select::Aborted | Select::Closed => {
                        self.receivers.unregister(oper).unwrap();
                        // If the channel was closed, we still have to check for remaining messages.
                    },
                    Select::Operation(_) => {},
                }
            })
        }
    }
/// Receives a message from the channel.
Receives a message from the channel.
Receives a message from the channel .
pub fn recv(&self) -> Option<T> {
        let token = &mut Token::default();
        let oper = Operation::hook(token);
        loop {
            // Try receiving a message several times.
            let backoff = &mut Backoff::new();
            loop {
                if self.start_recv(token, backoff) {
                    unsafe {
                        return self.read(token);
                    }
                }
                if !backoff.step() {
                    break;
                }
            }
            // Prepare for blocking until a sender wakes us up.
            context::with_current(|cx| {
                cx.reset();
                self.receivers.register(oper, cx);
                // Has the channel become ready just now?
                if !self.is_empty() || self.is_closed() {
                    let _ = cx.try_select(Select::Aborted);
                }
                // Block the current thread.
                let sel = cx.wait_until(None);
                match sel {
                    Select::Waiting => unreachable!(),
                    Select::Aborted | Select::Closed => {
                        self.receivers.unregister(oper).unwrap();
                        // If the channel was closed, we still have to check for remaining messages.
                    },
                    Select::Operation(_) => {},
                }
            })
        }
    }
pub fn recv ( & self ) -> Option < T > { let token = & mut Token :: default ( ) ; let oper = Operation :: hook ( token ) ; loop { // Try receiving a message several times. let backoff = & mut Backoff :: new ( ) ; loop { if self . start_recv ( token , backoff ) { unsafe { return self . read ( token ) ; } } if ! backoff . step ( ) { break ; } } // Prepare for blocking until a sender wakes us up. context :: with_current ( | cx | { cx . reset ( ) ; self . receivers . register ( oper , cx ) ; // Has the channel become ready just now? if ! self . is_empty ( ) || self . is_closed ( ) { let _ = cx . try_select ( Select :: Aborted ) ; } // Block the current thread. let sel = cx . wait_until ( None ) ; match sel { Select :: Waiting => unreachable ! ( ) , Select :: Aborted | Select :: Closed => { self . receivers . unregister ( oper ) . unwrap ( ) ; // If the channel was closed, we still have to check for remaining messages. } , Select :: Operation ( _ ) => { } , } } ) } }
Receives a message from the channel.
Receives a message from the channel .
&self