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()
});
loop {
match self.tasks.pop_runnable() {
Err(_) => break,
Ok(runnable) => {
panic::catch_unwind(|| runnable.run()).map_err(|err| {
gst_error!(
RUNTIME_CAT,
"A task has panicked within Context {}",
self.context_name
);
while let Ok(runnable) = self.tasks.pop_runnable() {
panic::catch_unwind(|| runnable.run()).map_err(|err| {
gst_error!(
RUNTIME_CAT,
"A task has panicked within Context {}",
self.context_name
);
err
})?;
}
}
err
})?;
}
let mut must_awake = self.must_awake.lock().unwrap();