diff --git a/runtime/src/task.rs b/runtime/src/task.rs index 5575bcf26b..bb7008556b 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -96,11 +96,14 @@ impl Task { where T: 'static, { + let mut last_stream = None; let mut select_all = stream::SelectAll::new(); let mut units = 0; for task in tasks.into_iter() { - if let Some(stream) = task.stream { + if let Some(stream) = task.stream + && let Some(stream) = last_stream.replace(stream) + { select_all.push(stream); } @@ -108,7 +111,12 @@ impl Task { } Self { - stream: Some(boxed_stream(select_all)), + stream: if select_all.is_empty() { + last_stream + } else { + select_all.extend(last_stream); + Some(boxed_stream(select_all)) + }, units, } }