fn block_on<F: Future>(&mut self, future: F) -> F::Output {
        enter(self, |scheduler, context| {
            let _enter = crate::runtime::enter(false);
            let waker = scheduler.spawner.waker_ref();
            let mut cx = std::task::Context::from_waker(&waker);

            pin!(future);

            'outer: loop {
                if let Ready(v) = crate::coop::budget(|| future.as_mut().poll(&mut cx)) {
                    return v;
                }

                for _ in 0..MAX_TASKS_PER_TICK {
                    // Get and increment the current tick
                    let tick = scheduler.tick;
                    scheduler.tick = scheduler.tick.wrapping_add(1);

                    let next = if tick % REMOTE_FIRST_INTERVAL == 0 {
                        scheduler
                            .spawner
                            .pop()
                            .or_else(|| context.tasks.borrow_mut().queue.pop_front())
                    } else {
                        context
                            .tasks
                            .borrow_mut()
                            .queue
                            .pop_front()
                            .or_else(|| scheduler.spawner.pop())
                    };

                    match next {
                        Some(task) => crate::coop::budget(|| task.run()),
                        None => {
                            // Park until the thread is signaled
                            scheduler.park.park().ok().expect("failed to park");

                            // Try polling the `block_on` future next
                            continue 'outer;
                        }
                    }
                }

                // Yield to the park, this drives the timer and pulls any pending
                // I/O events.
                scheduler
                    .park
                    .park_timeout(Duration::from_millis(0))
                    .ok()
                    .expect("failed to park");
            }
        })
    }
/// Block on the future provided and drive the runtime's driver.
Block on the future provided and drive the runtime's driver.
Block on the future provided and drive the runtime ' s driver .
fn block_on<F: Future>(&mut self, future: F) -> F::Output {
        enter(self, |scheduler, context| {
            let _enter = crate::runtime::enter(false);
            let waker = scheduler.spawner.waker_ref();
            let mut cx = std::task::Context::from_waker(&waker);
            pin!(future);
            'outer: loop {
                if let Ready(v) = crate::coop::budget(|| future.as_mut().poll(&mut cx)) {
                    return v;
                }
                for _ in 0..MAX_TASKS_PER_TICK {
                    // Get and increment the current tick
                    let tick = scheduler.tick;
                    scheduler.tick = scheduler.tick.wrapping_add(1);
                    let next = if tick % REMOTE_FIRST_INTERVAL == 0 {
                        scheduler
                            .spawner
                            .pop()
                            .or_else(|| context.tasks.borrow_mut().queue.pop_front())
                    } else {
                        context
                            .tasks
                            .borrow_mut()
                            .queue
                            .pop_front()
                            .or_else(|| scheduler.spawner.pop())
                    };
                    match next {
                        Some(task) => crate::coop::budget(|| task.run()),
                        None => {
                            // Park until the thread is signaled
                            scheduler.park.park().ok().expect("failed to park");
                            // Try polling the `block_on` future next
                            continue 'outer;
                        }
                    }
                }
                // Yield to the park, this drives the timer and pulls any pending
                // I/O events.
                scheduler
                    .park
                    .park_timeout(Duration::from_millis(0))
                    .ok()
                    .expect("failed to park");
            }
        })
    }
fn block_on < F : Future > ( & mut self , future : F ) -> F :: Output { enter ( self , | scheduler , context | { let _enter = crate :: runtime :: enter ( false ) ; let waker = scheduler . spawner . waker_ref ( ) ; let mut cx = std :: task :: Context :: from_waker ( & waker ) ; pin ! ( future ) ; ' outer : loop { if let Ready ( v ) = crate :: coop :: budget ( | | future . as_mut ( ) . poll ( & mut cx ) ) { return v ; } for _ in 0 .. MAX_TASKS_PER_TICK { // Get and increment the current tick let tick = scheduler . tick ; scheduler . tick = scheduler . tick . wrapping_add ( 1 ) ; let next = if tick % REMOTE_FIRST_INTERVAL == 0 { scheduler . spawner . pop ( ) . or_else ( | | context . tasks . borrow_mut ( ) . queue . pop_front ( ) ) } else { context . tasks . borrow_mut ( ) . queue . pop_front ( ) . or_else ( | | scheduler . spawner . pop ( ) ) } ; match next { Some ( task ) => crate :: coop :: budget ( | | task . run ( ) ) , None => { // Park until the thread is signaled scheduler . park . park ( ) . ok ( ) . expect ( " " ) ; // Try polling the `block_on` future next continue ' outer ; } } } // Yield to the park, this drives the timer and pulls any pending // I/O events. scheduler . park . park_timeout ( Duration :: from_millis ( 0 ) ) . ok ( ) . expect ( " " ) ; } } ) }
Block on the future provided and drive the runtime's driver.
Block on the future provided and drive the runtime ' s driver .
&mut self
future
F