unsafe fn try_wait(
        &mut self,
        wait_node: &mut ListNode<WaitQueueEntry>,
        cx: &mut Context<'_>,
    ) -> Poll<()> {
        match wait_node.state {
            PollState::New => {
                if self.is_set {
                    // The event is already signaled
                    wait_node.state = PollState::Done;
                    Poll::Ready(())
                } else {
                    // Added the task to the wait queue
                    wait_node.task = Some(cx.waker().clone());
                    wait_node.state = PollState::Waiting;
                    self.waiters.add_front(wait_node);
                    Poll::Pending
                }
            }
            PollState::Waiting => {
                // The WaitForEventFuture is already in the queue.
                // The event can't have been set, since this would change the
                // waitstate inside the mutex. However the caller might have
                // passed a different `Waker`. In this case we need to update it.
                update_waker_ref(&mut wait_node.task, cx);
                Poll::Pending
            }
            PollState::Done => {
                // We have been woken up by the event.
                // This does not guarantee that the event is still set. It could
                // have been reset it in the meantime.
                Poll::Ready(())
            }
        }
    }
/// Checks if the event is set. If it is this returns immediately.
/// If the event isn't set, the WaitForEventFuture gets added to the wait
/// queue at the event, 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.
Checks if the event is set. If it is this returns immediately.
If the event isn't set, the WaitForEventFuture gets added to the wait
queue at the event, 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.
Checks if the event is set . If it is this returns immediately . If the event isn ' t set the WaitForEventFuture gets added to the wait queue at the event 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_wait(
        &mut self,
        wait_node: &mut ListNode<WaitQueueEntry>,
        cx: &mut Context<'_>,
    ) -> Poll<()> {
        match wait_node.state {
            PollState::New => {
                if self.is_set {
                    // The event is already signaled
                    wait_node.state = PollState::Done;
                    Poll::Ready(())
                } else {
                    // Added the task to the wait queue
                    wait_node.task = Some(cx.waker().clone());
                    wait_node.state = PollState::Waiting;
                    self.waiters.add_front(wait_node);
                    Poll::Pending
                }
            }
            PollState::Waiting => {
                // The WaitForEventFuture is already in the queue.
                // The event can't have been set, since this would change the
                // waitstate inside the mutex. However the caller might have
                // passed a different `Waker`. In this case we need to update it.
                update_waker_ref(&mut wait_node.task, cx);
                Poll::Pending
            }
            PollState::Done => {
                // We have been woken up by the event.
                // This does not guarantee that the event is still set. It could
                // have been reset it in the meantime.
                Poll::Ready(())
            }
        }
    }
unsafe fn try_wait ( & mut self , wait_node : & mut ListNode < WaitQueueEntry > , cx : & mut Context < ' _ > , ) -> Poll < ( ) > { match wait_node . state { PollState :: New => { if self . is_set { // The event is already signaled wait_node . state = PollState :: Done ; Poll :: Ready ( ( ) ) } else { // Added the task to the wait queue wait_node . task = Some ( cx . waker ( ) . clone ( ) ) ; wait_node . state = PollState :: Waiting ; self . waiters . add_front ( wait_node ) ; Poll :: Pending } } PollState :: Waiting => { // The WaitForEventFuture is already in the queue. // The event can't have been set, since this would change the // waitstate inside the mutex. However the caller might have // passed a different `Waker`. In this case we need to update it. update_waker_ref ( & mut wait_node . task , cx ) ; Poll :: Pending } PollState :: Done => { // We have been woken up by the event. // This does not guarantee that the event is still set. It could // have been reset it in the meantime. Poll :: Ready ( ( ) ) } } }
Checks if the event is set.
Checks if the event is set .
&mut self
wait_node
&mut ListNode<WaitQueueEntry>
cx
&mut Context<'_>
&mut self
wait_node
&mut ListNode<WaitQueueEntry>
cx
&mut Context<'_>