Skip to content

Commit 0502813

Browse files
committed
feat: add JoinSet::spawn_local
1 parent dcbf737 commit 0502813

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/task.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ mod wasm {
9292
AbortHandle { state }
9393
}
9494

95+
/// Alias to [`Self::spawn`].
96+
///
97+
/// Mirrors [`tokio::JoinSet::spawn_local](https://docs.rs/tokio/latest/tokio/task/struct.JoinSet.html#method.spawn_local).
98+
/// Because all tasks in WebAssembly are local, this is a simple alias to [`Self::spawn`].
99+
pub fn spawn_local(&mut self, fut: impl IntoFuture<Output = T> + 'static) -> AbortHandle
100+
where
101+
T: 'static,
102+
{
103+
self.spawn(fut)
104+
}
105+
95106
/// Aborts all tasks inside this `JoinSet`
96107
pub fn abort_all(&self) {
97108
self.to_cancel.iter().for_each(JoinHandle::abort);

0 commit comments

Comments
 (0)