pub enum Chooser {
Record {
rng: SeededRng,
seed: SchedSeed,
choices: Vec<ChoicePoint>,
},
Replay {
trace: SchedTrace,
pos: usize,
},
}Expand description
The decision choke point: records (seeded) or replays scheduling choices.
THE single source of nondeterminism in the runtime — every scheduler choice
goes through Chooser::decide. Nothing else draws entropy.
Variants§
Record
Recording: draw from the seeded RNG and log each choice.
Replay
Replaying: re-issue the recorded choices, asserting the shapes still match.
Implementations§
Source§impl Chooser
impl Chooser
Sourcepub fn replay(trace: SchedTrace) -> Self
pub fn replay(trace: SchedTrace) -> Self
A replaying chooser that re-issues the decisions in trace.
Sourcepub fn decide(&mut self, kind: ChoiceKind, options: usize) -> usize
pub fn decide(&mut self, kind: ChoiceKind, options: usize) -> usize
Resolve one decision among options choices, returning the chosen index.
Record mode draws from the seeded RNG and logs the choice. Replay mode
returns the recorded choice, panicking if the decision shape diverges from
what was recorded (a different kind or options count, or running past
the end of the trace).
Sourcepub fn into_trace(self) -> SchedTrace
pub fn into_trace(self) -> SchedTrace
Finish and return the trace (returns the original trace for a replay chooser).