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

feature flag for debugging to make join functions #2767

Open
anatawa12 opened this issue Aug 4, 2023 · 0 comments
Open

feature flag for debugging to make join functions #2767

anatawa12 opened this issue Aug 4, 2023 · 0 comments

Comments

@anatawa12
Copy link

When I use debugger to debug my tool with try_join_all or other join functions in futures, I want to replace try_join_all with non-parallel versions for easy debugging.

I wrote helper functions like below but I wonder if some option to make join functions non-parallel.

async fn try_join_all<I>(iter: I) -> Result<Vec<<<I as IntoIterator>::Item as TryFuture>::Ok>, <<I as IntoIterator>::Item as TryFuture>::Error>
    where
        I: IntoIterator,
        I::Item: TryFuture {
    let mut vec = Vec::new();
    for mut fut in iter {
        let mut pinned = pin!(fut);
        vec.push(std::future::poll_fn(|c| pinned.as_mut().try_poll(c)).await?);
    }
    Ok(vec)
}

async fn join_all<I>(iter: I) -> Vec<<<I as IntoIterator>::Item as Future>::Output>
    where
        I: IntoIterator,
        I::Item: Future {
    let mut vec = Vec::new();
    for mut fut in iter {
        let mut pinned = pin!(fut);
        vec.push(pinned.as_mut().await);
    }
    vec
}

async fn join<A, B>(a: A, b: B) -> (<A as Future>::Output, <B as Future>::Output)
    where A: Future, B: Future {
    (a.await, b.await)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant