unsafe fn try_wait(
        &mut self,
        wait_node: &mut ListNode<TimerQueueEntry>,
        cx: &mut Context<'_>,
    ) -> Poll<()> {
        match wait_node.state {
            PollState::Unregistered => {
                let now = self.clock.now();
                if now >= wait_node.expiry {
                    // The timer is already expired
                    wait_node.state = PollState::Expired;
                    Poll::Ready(())
                }
                else {
                    // Added the task to the wait queue
                    wait_node.task = Some(cx.waker().clone());
                    wait_node.state = PollState::Registered;
                    self.waiters.add_sorted(wait_node);
                    Poll::Pending
                }
            },
            PollState::Registered => {
                // Since the timer wakes up all waiters and moves their states to
                // Expired when the timer expired, it can't be expired here yet
                Poll::Pending
            },
            PollState::Expired => {
                Poll::Ready(())
            },
        }
    }
/// Registers the timer future at the Timer.
/// 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.
Registers the timer future at the Timer.
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.
Registers the timer future at the Timer . 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<TimerQueueEntry>,
        cx: &mut Context<'_>,
    ) -> Poll<()> {
        match wait_node.state {
            PollState::Unregistered => {
                let now = self.clock.now();
                if now >= wait_node.expiry {
                    // The timer is already expired
                    wait_node.state = PollState::Expired;
                    Poll::Ready(())
                }
                else {
                    // Added the task to the wait queue
                    wait_node.task = Some(cx.waker().clone());
                    wait_node.state = PollState::Registered;
                    self.waiters.add_sorted(wait_node);
                    Poll::Pending
                }
            },
            PollState::Registered => {
                // Since the timer wakes up all waiters and moves their states to
                // Expired when the timer expired, it can't be expired here yet
                Poll::Pending
            },
            PollState::Expired => {
                Poll::Ready(())
            },
        }
    }
unsafe fn try_wait ( & mut self , wait_node : & mut ListNode < TimerQueueEntry > , cx : & mut Context < ' _ > , ) -> Poll < ( ) > { match wait_node . state { PollState :: Unregistered => { let now = self . clock . now ( ) ; if now >= wait_node . expiry { // The timer is already expired wait_node . state = PollState :: Expired ; Poll :: Ready ( ( ) ) } else { // Added the task to the wait queue wait_node . task = Some ( cx . waker ( ) . clone ( ) ) ; wait_node . state = PollState :: Registered ; self . waiters . add_sorted ( wait_node ) ; Poll :: Pending } } , PollState :: Registered => { // Since the timer wakes up all waiters and moves their states to // Expired when the timer expired, it can't be expired here yet Poll :: Pending } , PollState :: Expired => { Poll :: Ready ( ( ) ) } , } }
Registers the timer future at the Timer.
Registers the timer future at the Timer .
&mut self
wait_node
&mut ListNode<TimerQueueEntry>
cx
&mut Context<'_>
&mut self
wait_node
&mut ListNode<TimerQueueEntry>
cx
&mut Context<'_>