ts/runtime: rewrite runnable loop

Previous version relied on a plain loop / match / break because
I experimented different strategies. The while variant is better
for the final solution.
This commit is contained in:
François Laignel 2022-01-05 17:48:03 +01:00
parent 8bab034bc8
commit 1573522520

View file

@ -200,21 +200,16 @@ impl Scheduler {
reactor.react().ok() reactor.react().ok()
}); });
loop { while let Ok(runnable) = self.tasks.pop_runnable() {
match self.tasks.pop_runnable() { panic::catch_unwind(|| runnable.run()).map_err(|err| {
Err(_) => break, gst_error!(
Ok(runnable) => { RUNTIME_CAT,
panic::catch_unwind(|| runnable.run()).map_err(|err| { "A task has panicked within Context {}",
gst_error!( self.context_name
RUNTIME_CAT, );
"A task has panicked within Context {}",
self.context_name
);
err err
})?; })?;
}
}
} }
let mut must_awake = self.must_awake.lock().unwrap(); let mut must_awake = self.must_awake.lock().unwrap();