Trait shuttle::scheduler::Scheduler[][src]

pub trait Scheduler: Debug {
    fn new_execution(&mut self) -> Option<Schedule>;
fn next_task(
        &mut self,
        runnable_tasks: &[TaskId],
        current_task: Option<TaskId>,
        is_yielding: bool
    ) -> Option<TaskId>;
fn next_u64(&mut self) -> u64; }
Expand description

A Scheduler is an oracle that decides the order in which to execute concurrent tasks and the data to return to calls for random values.

TheScheduler lives across multiple executions of the test case, allowing it to retain some state and strategically explore different schedules. At the start of each test execution, the executor calls new_execution() to inform the scheduler that a new execution is starting. Then, for each scheduling decision, the executor calls next_task to determine which task to run.

Required methods

Inform the Scheduler that a new execution is about to begin. If this function returns None, the test will end rather than performing another execution. If it returns Some(schedule), the returned Schedule can be used to initialize a ReplayScheduler for deterministic replay.

Decide which task to run next, given a list of runnable tasks and the currently running tasks. This method returns Some(task) where task is the runnable task to be executed next; it may also return None, indicating that the execution engine should stop exploring the current schedule.

is_yielding is a hint to the scheduler that current_task has asked to yield (e.g., during a spin loop) and should be deprioritized.

The list of runnable tasks is guaranteed to be non-empty. If current_task is None, the execution has not yet begun.

Choose the next u64 value to return to the currently running task.

Implementations on Foreign Types

Implementors