Replicate diagnostic summaries

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Max Brunsfeld 2022-01-04 14:29:22 -08:00
parent b2f0c78924
commit d8b888c9cb
7 changed files with 231 additions and 50 deletions

View file

@ -206,10 +206,7 @@ impl Deterministic {
}
let state = self.state.lock();
if state.scheduled_from_foreground.is_empty()
&& state.scheduled_from_background.is_empty()
&& state.spawned_from_foreground.is_empty()
{
if state.would_park() {
return None;
}
}
@ -261,6 +258,14 @@ impl Deterministic {
}
}
impl DeterministicState {
fn would_park(&self) -> bool {
self.scheduled_from_foreground.is_empty()
&& self.scheduled_from_background.is_empty()
&& self.spawned_from_foreground.is_empty()
}
}
#[derive(Default)]
struct Trace {
executed: Vec<Backtrace>,
@ -433,6 +438,13 @@ impl Foreground {
*any_value.downcast().unwrap()
}
pub fn would_park(&self) -> bool {
match self {
Self::Deterministic(executor) => executor.state.lock().would_park(),
_ => panic!("this method can only be called on a deterministic executor"),
}
}
pub fn forbid_parking(&self) {
match self {
Self::Deterministic(executor) => {