fn run_in_fake_time<F>(executor: &mut TestExecutor, main_fut: &mut F, total_duration: Duration)
    where
        F: Future<Output = ()> + Unpin,
    {
        const INCREMENT: Duration = zx::Duration::from_millis(13);
        // Run the loop for a bit longer than the fake time needed to pump all
        // the events, to allow the event queue to drain.
        let total_duration = total_duration + SLACK_DURATION;
        let mut current = zx::Duration::from_millis(0);
        let mut poll_status = Poll::Pending;

        // We run until either the future completes or the timeout is reached,
        // whichever comes first.
        // Running the future after it returns Poll::Ready is not allowed, so
        // we must exit the loop then.
        while current < total_duration && poll_status == Poll::Pending {
            executor.set_fake_time(Time::after(INCREMENT));
            executor.wake_expired_timers();
            poll_status = executor.run_until_stalled(main_fut);
            current = current + INCREMENT;
        }
        assert_eq!(
            poll_status,
            Poll::Ready(()),
            "the main future did not complete, perhaps increase total_duration?"
        );
    }
// Run the future `main_fut` in fake time.  The fake time is being advanced
// in relatively small increments until a specified `total_duration` has
// elapsed.
//
// This complication is needed to ensure that any expired
// timers are awoken in the correct sequence because the test executor does
// not automatically wake the timers. For the fake time execution to
// be comparable to a real time execution, we need each timer to have the
// chance of waking up, so that we can properly process the consequences
// of that timer firing.
//
// We require that `main_fut` has completed at `total_duration`, and panic
// if it has not.  This ensures that we never block forever in fake time.
//
// This method could possibly be implemented in [TestExecutor] for those
// test executor users who do not care to wake the timers in any special
// way.
Run the future `main_fut` in fake time.  The fake time is being advanced
in relatively small increments until a specified `total_duration` has
elapsed.

This complication is needed to ensure that any expired
timers are awoken in the correct sequence because the test executor does
not automatically wake the timers. For the fake time execution to
be comparable to a real time execution, we need each timer to have the
chance of waking up, so that we can properly process the consequences
of that timer firing.

We require that `main_fut` has completed at `total_duration`, and panic
if it has not.  This ensures that we never block forever in fake time.

This method could possibly be implemented in [TestExecutor] for those
test executor users who do not care to wake the timers in any special
way.
Run the future ` main_fut ` in fake time . The fake time is being advanced in relatively small increments until a specified ` total_duration ` has elapsed . This complication is needed to ensure that any expired timers are awoken in the correct sequence because the test executor does not automatically wake the timers . For the fake time execution to be comparable to a real time execution we need each timer to have the chance of waking up so that we can properly process the consequences of that timer firing . We require that ` main_fut ` has completed at ` total_duration ` and panic if it has not . This ensures that we never block forever in fake time . This method could possibly be implemented in [ TestExecutor ] for those test executor users who do not care to wake the timers in any special way .
fn run_in_fake_time<F>(executor: &mut TestExecutor, main_fut: &mut F, total_duration: Duration)
    where
        F: Future<Output = ()> + Unpin,
    {
        const INCREMENT: Duration = zx::Duration::from_millis(13);
        // Run the loop for a bit longer than the fake time needed to pump all
        // the events, to allow the event queue to drain.
        let total_duration = total_duration + SLACK_DURATION;
        let mut current = zx::Duration::from_millis(0);
        let mut poll_status = Poll::Pending;
        // We run until either the future completes or the timeout is reached,
        // whichever comes first.
        // Running the future after it returns Poll::Ready is not allowed, so
        // we must exit the loop then.
        while current < total_duration && poll_status == Poll::Pending {
            executor.set_fake_time(Time::after(INCREMENT));
            executor.wake_expired_timers();
            poll_status = executor.run_until_stalled(main_fut);
            current = current + INCREMENT;
        }
        assert_eq!(
            poll_status,
            Poll::Ready(()),
            "the main future did not complete, perhaps increase total_duration?"
        );
    }
fn run_in_fake_time < F > ( executor : & mut TestExecutor , main_fut : & mut F , total_duration : Duration ) where F : Future < Output = ( ) > + Unpin , { const INCREMENT : Duration = zx :: Duration :: from_millis ( 13 ) ; // Run the loop for a bit longer than the fake time needed to pump all // the events, to allow the event queue to drain. let total_duration = total_duration + SLACK_DURATION ; let mut current = zx :: Duration :: from_millis ( 0 ) ; let mut poll_status = Poll :: Pending ; // We run until either the future completes or the timeout is reached, // whichever comes first. // Running the future after it returns Poll::Ready is not allowed, so // we must exit the loop then. while current < total_duration && poll_status == Poll :: Pending { executor . set_fake_time ( Time :: after ( INCREMENT ) ) ; executor . wake_expired_timers ( ) ; poll_status = executor . run_until_stalled ( main_fut ) ; current = current + INCREMENT ; } assert_eq ! ( poll_status Poll Ready ( ( ) ) " " ) ; }
Run the future `main_fut` in fake time.
Run the future ` main_fut ` in fake time .
executor
&mut TestExecutor
main_fut
&mut F
total_duration
Duration
executor
&mut TestExecutor
main_fut
&mut F
total_duration
Duration