unsafe fn try_receive(
        &mut self,
        wait_node: &mut ListNode<RecvWaitQueueEntry>,
        cx: &mut Context<'_>,
    ) -> Poll<Option<T>> {
        match wait_node.state {
            RecvPollState::Unregistered => {
                match &self.value {
                    Some(v) => {
                        // A value was available inside the channel and was fetched.
                        // TODO: If the same waiter asks again, they will always
                        // get the same value, instead of `None`. Is that reasonable?
                        Poll::Ready(Some(v.clone()))
                    },
                    None => {
                        // Check if something was written into the channel before
                        // or the channel was closed.
                        if self.is_fulfilled {
                            Poll::Ready(None)
                        }
                        else {
                            // Added the task to the wait queue
                            wait_node.task = Some(cx.waker().clone());
                            wait_node.state = RecvPollState::Registered;
                            self.waiters.add_front(wait_node);
                            Poll::Pending
                        }
                    },
                }
            },
            RecvPollState::Registered => {
                // Since the channel wakes up all waiters and moves their states to unregistered
                // there can't be any value in the channel in this state.
                Poll::Pending
            },
            RecvPollState::Notified => {
                unreachable!("Not possible for Oneshot Broadcast");
            },
        }
    }
/// Tries to read the value from the channel.
/// If the value isn't available yet, the ChannelReceiveFuture gets added to the
/// wait queue at the channel, and will be signalled once ready.
/// This function is only safe as long as the `wait_node`s address is guaranteed
/// to be stable until it gets removed from the queue.
Tries to read the value from the channel.
If the value isn't available yet, the ChannelReceiveFuture gets added to the
wait queue at the channel, and will be signalled once ready.
This function is only safe as long as the `wait_node`s address is guaranteed
to be stable until it gets removed from the queue.
Tries to read the value from the channel . If the value isn ' t available yet the ChannelReceiveFuture gets added to the wait queue at the channel and will be signalled once ready . This function is only safe as long as the ` wait_node ` s address is guaranteed to be stable until it gets removed from the queue .
unsafe fn try_receive(
        &mut self,
        wait_node: &mut ListNode<RecvWaitQueueEntry>,
        cx: &mut Context<'_>,
    ) -> Poll<Option<T>> {
        match wait_node.state {
            RecvPollState::Unregistered => {
                match &self.value {
                    Some(v) => {
                        // A value was available inside the channel and was fetched.
                        // TODO: If the same waiter asks again, they will always
                        // get the same value, instead of `None`. Is that reasonable?
                        Poll::Ready(Some(v.clone()))
                    },
                    None => {
                        // Check if something was written into the channel before
                        // or the channel was closed.
                        if self.is_fulfilled {
                            Poll::Ready(None)
                        }
                        else {
                            // Added the task to the wait queue
                            wait_node.task = Some(cx.waker().clone());
                            wait_node.state = RecvPollState::Registered;
                            self.waiters.add_front(wait_node);
                            Poll::Pending
                        }
                    },
                }
            },
            RecvPollState::Registered => {
                // Since the channel wakes up all waiters and moves their states to unregistered
                // there can't be any value in the channel in this state.
                Poll::Pending
            },
            RecvPollState::Notified => {
                unreachable!("Not possible for Oneshot Broadcast");
            },
        }
    }
unsafe fn try_receive ( & mut self , wait_node : & mut ListNode < RecvWaitQueueEntry > , cx : & mut Context < ' _ > , ) -> Poll < Option < T > > { match wait_node . state { RecvPollState :: Unregistered => { match & self . value { Some ( v ) => { // A value was available inside the channel and was fetched. // TODO: If the same waiter asks again, they will always // get the same value, instead of `None`. Is that reasonable? Poll :: Ready ( Some ( v . clone ( ) ) ) } , None => { // Check if something was written into the channel before // or the channel was closed. if self . is_fulfilled { Poll :: Ready ( None ) } else { // Added the task to the wait queue wait_node . task = Some ( cx . waker ( ) . clone ( ) ) ; wait_node . state = RecvPollState :: Registered ; self . waiters . add_front ( wait_node ) ; Poll :: Pending } } , } } , RecvPollState :: Registered => { // Since the channel wakes up all waiters and moves their states to unregistered // there can't be any value in the channel in this state. Poll :: Pending } , RecvPollState :: Notified => { unreachable ! ( " " ) ; } , } }
Tries to read the value from the channel.
Tries to read the value from the channel .
&mut self
wait_node
&mut ListNode<RecvWaitQueueEntry>
cx
&mut Context<'_>
&mut self
wait_node
&mut ListNode<RecvWaitQueueEntry>
cx
&mut Context<'_>