pub fn run_singlethreaded<F>(&mut self, main_future: F) -> F::Output
    where
        F: Future,
    {
        pin_mut!(main_future);
        let waker = self.singlethreaded_main_task_wake();
        let main_cx = &mut Context::from_waker(&waker);
        let mut res = main_future.as_mut().poll(main_cx);

        loop {
            if let Poll::Ready(res) = res {
                return res;
            }

            let packet = with_local_timer_heap(|timer_heap| {
                let deadline = next_deadline(timer_heap)
                    .map(|t| t.time)
                    .unwrap_or(zx::Time::INFINITE);
                match self.inner.port.wait(deadline) {
                    Ok(packet) => Some(packet),
                    Err(zx::Status::TIMED_OUT) => {
                        let time_waker = timer_heap.pop().unwrap();
                        time_waker.wake();
                        None
                    }
                    Err(status) => {
                        panic!("Error calling port wait: {:?}", status);
                    }
                }
            });

            if let Some(packet) = packet {
                match packet.key() {
                    EMPTY_WAKEUP_ID => {
                        res = main_future.as_mut().poll(main_cx);
                    }
                    TASK_READY_WAKEUP_ID => self.inner.poll_ready_tasks(),
                    receiver_key => {
                        self.inner.deliver_packet(receiver_key as usize, packet);
                    }
                }
            }
        }
    }
/// Run a single future to completion on a single thread.
// Takes `&mut self` to ensure that only one thread-manager is running at a time.
Run a single future to completion on a single thread.
Takes `&mut self` to ensure that only one thread-manager is running at a time.
Run a single future to completion on a single thread . Takes ` &mut self ` to ensure that only one thread - manager is running at a time .
pub fn run_singlethreaded<F>(&mut self, main_future: F) -> F::Output
    where
        F: Future,
    {
        pin_mut!(main_future);
        let waker = self.singlethreaded_main_task_wake();
        let main_cx = &mut Context::from_waker(&waker);
        let mut res = main_future.as_mut().poll(main_cx);
        loop {
            if let Poll::Ready(res) = res {
                return res;
            }
            let packet = with_local_timer_heap(|timer_heap| {
                let deadline = next_deadline(timer_heap)
                    .map(|t| t.time)
                    .unwrap_or(zx::Time::INFINITE);
                match self.inner.port.wait(deadline) {
                    Ok(packet) => Some(packet),
                    Err(zx::Status::TIMED_OUT) => {
                        let time_waker = timer_heap.pop().unwrap();
                        time_waker.wake();
                        None
                    }
                    Err(status) => {
                        panic!("Error calling port wait: {:?}", status);
                    }
                }
            });
            if let Some(packet) = packet {
                match packet.key() {
                    EMPTY_WAKEUP_ID => {
                        res = main_future.as_mut().poll(main_cx);
                    }
                    TASK_READY_WAKEUP_ID => self.inner.poll_ready_tasks(),
                    receiver_key => {
                        self.inner.deliver_packet(receiver_key as usize, packet);
                    }
                }
            }
        }
    }
pub fn run_singlethreaded < F > ( & mut self , main_future : F ) -> F :: Output where F : Future , { pin_mut ! ( main_future ) ; let waker = self . singlethreaded_main_task_wake ( ) ; let main_cx = & mut Context :: from_waker ( & waker ) ; let mut res = main_future . as_mut ( ) . poll ( main_cx ) ; loop { if let Poll :: Ready ( res ) = res { return res ; } let packet = with_local_timer_heap ( | timer_heap | { let deadline = next_deadline ( timer_heap ) . map ( | t | t . time ) . unwrap_or ( zx :: Time :: INFINITE ) ; match self . inner . port . wait ( deadline ) { Ok ( packet ) => Some ( packet ) , Err ( zx :: Status :: TIMED_OUT ) => { let time_waker = timer_heap . pop ( ) . unwrap ( ) ; time_waker . wake ( ) ; None } Err ( status ) => { panic ! ( " " status ) ; } } } ) ; if let Some ( packet ) = packet { match packet . key ( ) { EMPTY_WAKEUP_ID => { res = main_future . as_mut ( ) . poll ( main_cx ) ; } TASK_READY_WAKEUP_ID => self . inner . poll_ready_tasks ( ) , receiver_key => { self . inner . deliver_packet ( receiver_key as usize , packet ) ; } } } } }
Run a single future to completion on a single thread.
Run a single future to completion on a single thread .
&mut self
main_future
F
&mut self
main_future
F