fn schedule(&mut self, has_yielded: bool) {
        // Don't schedule twice. If `maybe_yield` ran the scheduler, we don't want to run it
        // again at the top of `step`.
        if self.next_task != ScheduledTask::None {
            return;
        }

        match self.config.max_steps {
            MaxSteps::None => {}
            MaxSteps::FailAfter(n) => {
                if self.current_schedule.len() >= n {
                    if has_yielded {
                        panic!(
                            "{}",
                            persist_failure(
                                &self.current_schedule,
                                format!("exceeded max_steps bound {}. this might be caused by an unfair schedule (e.g., a spin loop)?", n),
                                &self.config
                            )
                        );
                    } else {
                        // Force this task to yield; we'll trigger the panic next time we call `schedule`
                        self.next_task = ScheduledTask::None;
                        return;
                    }
                }
            }
            MaxSteps::ContinueAfter(n) => {
                if self.current_schedule.len() >= n {
                    self.next_task = ScheduledTask::Stopped;
                    return;
                }
            }
        }

        let runnable = self
            .tasks
            .iter()
            .filter(|t| t.runnable())
            .map(|t| t.id)
            .collect::<SmallVec<[_; DEFAULT_INLINE_TASKS]>>();

        if runnable.is_empty() {
            self.next_task = ScheduledTask::Finished;
            return;
        }

        let is_yielding = std::mem::replace(&mut self.has_yielded, false);

        self.next_task = self
            .scheduler
            .borrow_mut()
            .next_task(&runnable, self.current_task.id(), is_yielding)
            .map(ScheduledTask::Some)
            .unwrap_or(ScheduledTask::Stopped);

        trace!(?runnable, next_task=?self.next_task);
    }
/// Run the scheduler to choose the next task to run. `has_yielded` should be false if the
/// scheduler is being invoked from within a running task, in which case `schedule` should not
/// panic.
Run the scheduler to choose the next task to run. `has_yielded` should be false if the
scheduler is being invoked from within a running task, in which case `schedule` should not
panic.
Run the scheduler to choose the next task to run . ` has_yielded ` should be false if the scheduler is being invoked from within a running task in which case ` schedule ` should not panic .
fn schedule(&mut self, has_yielded: bool) {
        // Don't schedule twice. If `maybe_yield` ran the scheduler, we don't want to run it
        // again at the top of `step`.
        if self.next_task != ScheduledTask::None {
            return;
        }
        match self.config.max_steps {
            MaxSteps::None => {}
            MaxSteps::FailAfter(n) => {
                if self.current_schedule.len() >= n {
                    if has_yielded {
                        panic!(
                            "{}",
                            persist_failure(
                                &self.current_schedule,
                                format!("exceeded max_steps bound {}. this might be caused by an unfair schedule (e.g., a spin loop)?", n),
                                &self.config
                            )
                        );
                    } else {
                        // Force this task to yield; we'll trigger the panic next time we call `schedule`
                        self.next_task = ScheduledTask::None;
                        return;
                    }
                }
            }
            MaxSteps::ContinueAfter(n) => {
                if self.current_schedule.len() >= n {
                    self.next_task = ScheduledTask::Stopped;
                    return;
                }
            }
        }
        let runnable = self
            .tasks
            .iter()
            .filter(|t| t.runnable())
            .map(|t| t.id)
            .collect::<SmallVec<[_; DEFAULT_INLINE_TASKS]>>();
        if runnable.is_empty() {
            self.next_task = ScheduledTask::Finished;
            return;
        }
        let is_yielding = std::mem::replace(&mut self.has_yielded, false);
        self.next_task = self
            .scheduler
            .borrow_mut()
            .next_task(&runnable, self.current_task.id(), is_yielding)
            .map(ScheduledTask::Some)
            .unwrap_or(ScheduledTask::Stopped);
        trace!(?runnable, next_task=?self.next_task);
    }
fn schedule ( & mut self , has_yielded : bool ) { // Don't schedule twice. If `maybe_yield` ran the scheduler, we don't want to run it // again at the top of `step`. if self . next_task != ScheduledTask :: None { return ; } match self . config . max_steps { MaxSteps :: None => { } MaxSteps :: FailAfter ( n ) => { if self . current_schedule . len ( ) >= n { if has_yielded { panic ! ( " " persist_failure ( self current_schedule format ( " " n ) self config ) ) ; } else { // Force this task to yield; we'll trigger the panic next time we call `schedule` self . next_task = ScheduledTask :: None ; return ; } } } MaxSteps :: ContinueAfter ( n ) => { if self . current_schedule . len ( ) >= n { self . next_task = ScheduledTask :: Stopped ; return ; } } } let runnable = self . tasks . iter ( ) . filter ( | t | t . runnable ( ) ) . map ( | t | t . id ) . collect :: < SmallVec < [ _ ; DEFAULT_INLINE_TASKS ] > > ( ) ; if runnable . is_empty ( ) { self . next_task = ScheduledTask :: Finished ; return ; } let is_yielding = std :: mem :: replace ( & mut self . has_yielded , false ) ; self . next_task = self . scheduler . borrow_mut ( ) . next_task ( & runnable , self . current_task . id ( ) , is_yielding ) . map ( ScheduledTask :: Some ) . unwrap_or ( ScheduledTask :: Stopped ) ; trace ! ( runnable next_task self next_task ) ; }
Run the scheduler to choose the next task to run.
Run the scheduler to choose the next task to run .
&mut self
has_yielded
bool
&mut self
has_yielded
bool