There was an error while loading. Please reload this page.
Task::batch
1 parent d188d6f commit 1938a8dCopy full SHA for 1938a8d
1 file changed
runtime/src/task.rs
@@ -96,19 +96,27 @@ impl<T> Task<T> {
96
where
97
T: 'static,
98
{
99
+ let mut last_stream = None;
100
let mut select_all = stream::SelectAll::new();
101
let mut units = 0;
102
103
for task in tasks.into_iter() {
- if let Some(stream) = task.stream {
104
+ if let Some(stream) = task.stream
105
+ && let Some(stream) = last_stream.replace(stream)
106
+ {
107
select_all.push(stream);
108
}
109
110
units += task.units;
111
112
113
Self {
- stream: Some(boxed_stream(select_all)),
114
+ stream: if select_all.is_empty() {
115
+ last_stream
116
+ } else {
117
+ select_all.extend(last_stream);
118
+ Some(boxed_stream(select_all))
119
+ },
120
units,
121
122
0 commit comments