pub fn wait_for_run(&self) -> impl Future<Output = Box<UserContext>> {
        #[must_use = "wait_for_run does nothing unless polled/`await`-ed"]
        struct RunnableChecker {
            thread: Arc<Thread>,
        }
        impl Future for RunnableChecker {
            type Output = Box<UserContext>;

            fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
                let mut inner = self.thread.inner.lock();
                if inner.state() != ThreadState::Suspended {
                    // resume:  return the context token from thread object
                    // There is no need to call change_state here
                    // since take away the context of a non-suspended thread won't change it's state
                    Poll::Ready(inner.context.take().unwrap())
                } else {
                    // suspend: put waker into the thread object
                    inner.waker = Some(cx.waker().clone());
                    Poll::Pending
                }
            }
        }
        RunnableChecker {
            thread: self.0.clone(),
        }
    }
/// Wait until the thread is ready to run (not suspended),
/// and then take away its context to run the thread.
Wait until the thread is ready to run (not suspended),
and then take away its context to run the thread.
Wait until the thread is ready to run ( not suspended ) and then take away its context to run the thread .
pub fn wait_for_run(&self) -> impl Future<Output = Box<UserContext>> {
        #[must_use = "wait_for_run does nothing unless polled/`await`-ed"]
        struct RunnableChecker {
            thread: Arc<Thread>,
        }
        impl Future for RunnableChecker {
            type Output = Box<UserContext>;
            fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
                let mut inner = self.thread.inner.lock();
                if inner.state() != ThreadState::Suspended {
                    // resume:  return the context token from thread object
                    // There is no need to call change_state here
                    // since take away the context of a non-suspended thread won't change it's state
                    Poll::Ready(inner.context.take().unwrap())
                } else {
                    // suspend: put waker into the thread object
                    inner.waker = Some(cx.waker().clone());
                    Poll::Pending
                }
            }
        }
        RunnableChecker {
            thread: self.0.clone(),
        }
    }
pub fn wait_for_run ( & self ) -> impl Future < Output = Box < UserContext > > { # [ must_use = " " ] struct RunnableChecker { thread : Arc < Thread > , } impl Future for RunnableChecker { type Output = Box < UserContext > ; fn poll ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < Self :: Output > { let mut inner = self . thread . inner . lock ( ) ; if inner . state ( ) != ThreadState :: Suspended { // resume:  return the context token from thread object // There is no need to call change_state here // since take away the context of a non-suspended thread won't change it's state Poll :: Ready ( inner . context . take ( ) . unwrap ( ) ) } else { // suspend: put waker into the thread object inner . waker = Some ( cx . waker ( ) . clone ( ) ) ; Poll :: Pending } } } RunnableChecker { thread : self . 0 . clone ( ) , } }
Wait until the thread is ready to run (not suspended),
and then take away its context to run the thread.
Wait until the thread is ready to run ( not suspended ) and then take away its context to run the thread .
&self
&self