I want to able to start a future running in the background, and not wait for it immediately in the parent function scope.
Something like a dynamic join_all
where I can add new futures in a loop to a set, and then pass the set to another function which can .await the whole set (that is already running).
I want to be able to do something like this:
join_all(vec![
log_arg(&c),
log_arg(&c)
]).await;
But the issues are:
.await
starts the future executing, but also waits for it at the current function.- How do I start the execution without waiting for it?
&c
is not'static
- Seems to be a requirement for all of the Tokio API's that "start the future executing without waiting for the result in the current fn scope", e.g
spawn_local
- It is OK if all the futures are on a single thread.
- Seems to be a requirement for all of the Tokio API's that "start the future executing without waiting for the result in the current fn scope", e.g
Example: