futures-rs icon indicating copy to clipboard operation
futures-rs copied to clipboard

FuturesUnordered with concurrency control

Open msmouse opened this issue 3 years ago • 0 comments

We needed a clean way to do things like buffered(n) but with limited number of futures being drived at the same time, particularly useful is try_bufferred_x(n, 1), where those futures are completed one after another but the results are buffered ahead of the downstream consuming them.

We implemented it from a FuturesUnorderedX that has a max_in_progress parameter, and built on top of it to have FuturesOrderedX, BufferedX, TryBufferedX, starting from here: https://github.com/diem/diem/blob/main/storage/backup/backup-cli/src/utils/stream/futures_unordered_x.rs#L4-L6

I wonder is there a cleaner way directly based on the existing futures interfaces, or shall I ask the library to integrate such functionalities?

Thank you!

msmouse avatar Dec 02 '21 17:12 msmouse