Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a join_all convenience function #7034

Open
FalkWoldmann opened this issue Dec 13, 2024 · 1 comment
Open

Implement a join_all convenience function #7034

FalkWoldmann opened this issue Dec 13, 2024 · 1 comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-task Module: tokio/task

Comments

@FalkWoldmann
Copy link

Is your feature request related to a problem? Please describe.
In issue #6664, the convenience method join_all was introduced for the JoinSet. To enhance this further, it would be nice to implement a join_all function that accepts any type implementing IntoIterator and containing futures. This would improve usability and convenience. This would be similar to the join_all function from the futures crate.

Describe the solution you'd like
I came up with the following:

pub async fn join_all<T: Send + 'static>(futures: impl IntoIterator<Item=impl Future<Output=T> + Send + 'static>) -> Vec<T> {
    futures.into_iter().collect::<JoinSet<T>>().join_all().await
}

The question would be, where to put this function. Perhaps to tokio::task?

@FalkWoldmann FalkWoldmann added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Dec 13, 2024
@Noah-Kennedy
Copy link
Contributor

tokio-util is probably a better place for this if we were to do it

We try and keep these sorts of utility things outside of the main crate generally.

@Darksonn Darksonn added the M-task Module: tokio/task label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-task Module: tokio/task
Projects
None yet
Development

No branches or pull requests

3 participants