Skip to content

Commit d3784f9

Browse files
authored
add JoinSet::join_all() (#60)
1 parent 91db289 commit d3784f9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

msim/src/sim/task/join_set.rs

+13
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ impl<T: 'static> JoinSet<T> {
8787
while self.join_next().await.is_some() {}
8888
}
8989

90+
pub async fn join_all(mut self) -> Vec<T> {
91+
let mut output = Vec::with_capacity(self.len());
92+
93+
while let Some(res) = self.join_next().await {
94+
match res {
95+
Ok(t) => output.push(t),
96+
Err(err) if err.is_panic() => std::panic::resume_unwind(err.into_panic()),
97+
Err(err) => panic!("{err}"),
98+
}
99+
}
100+
output
101+
}
102+
90103
pub fn abort_all(&mut self) {
91104
self.inner.iter().for_each(|jh| jh.abort());
92105
}

0 commit comments

Comments
 (0)