threadshare/runtime: Drain pending sub tasks in a loop

A pending sub task might add new pending sub tasks that have to be
handled first.
This commit is contained in:
Sebastian Dröge 2020-03-16 15:02:30 +02:00
parent fa7cc9826d
commit 12dcca3f17
2 changed files with 13 additions and 5 deletions

View file

@ -419,7 +419,9 @@ impl PadSrcStrong {
})?;
gst_log!(RUNTIME_CAT, obj: self.gst_pad(), "Processing any pending sub tasks");
Context::drain_sub_tasks().await?;
while Context::current_has_sub_tasks() {
Context::drain_sub_tasks().await?;
}
Ok(success)
}
@ -439,7 +441,9 @@ impl PadSrcStrong {
})?;
gst_log!(RUNTIME_CAT, obj: self.gst_pad(), "Processing any pending sub tasks");
Context::drain_sub_tasks().await?;
while Context::current_has_sub_tasks() {
Context::drain_sub_tasks().await?;
}
Ok(success)
}
@ -451,8 +455,10 @@ impl PadSrcStrong {
let was_handled = self.gst_pad().push_event(event);
gst_log!(RUNTIME_CAT, obj: self.gst_pad(), "Processing any pending sub tasks");
if Context::drain_sub_tasks().await.is_err() {
return false;
while Context::current_has_sub_tasks() {
if Context::drain_sub_tasks().await.is_err() {
return false;
}
}
was_handled

View file

@ -115,7 +115,9 @@ impl Task {
gst_trace!(RUNTIME_CAT, "Task prepare function finished");
Context::drain_sub_tasks().await?;
while Context::current_has_sub_tasks() {
Context::drain_sub_tasks().await?;
}
// Once the prepare function is finished we can forget the corresponding
// handles so that unprepare and friends don't have to block on it anymore