-
Notifications
You must be signed in to change notification settings - Fork 638
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
Visit all futures in FuturesUnordered #605
Comments
Is there a reason why adding an iterator that iterates over the inner futures doesn't work (vs a callback)? |
Ah, yes, an iterator over mutable references should work too. |
Various iterators (iter_mut/into_iter/drain/etc) sound like a good idea to me! |
@srijs, thank you! Now I'm waiting for a release :) This ticket might be closed indeed. |
Oh, sorry. I've missed one detail when reading comments: the original proposal was to use a closure because everything done in that closure must wake up an inner future not just the parent future holding the FuturesUnordered object. (The drain proposal would work because it would push futures back to the new collection). So while |
@tailhook Ah, I see. So to clarify, you'd like to iterate over the futures in Since a new release hasn't been cut yet, we might have the chance to still change the API to support what you'd like to have. If the Specifically, I'm thinking of something like EDIT: Alternatively, the Not 100% sure if that's feasible yet, but I can take a look later today. What do you think? |
Basically, I want I think using Also, if we're looking for a similar operation in stdlib we can use |
My use case is: I have a set of futures each following its own stream which it processes and sends result over its own channel. But when the configuration is updated I need to visit every future and check if everything in the future's state is up to date.
The proposed API:
Or alternatively, just allow to recover futures from the collection:
(note the latter would require
mem::replace
forFuturesUnordered
for the use case, but is probably acceptable too)Currently, the simplest solution I could find is:
Shared<()>
into each futureShared
is ready, yield internal state as a result of the futureFuturesUnordered::poll
and reconstruct the future with a newShared<()>
future (waiting for next update)The alternative strategy might be:
Arc<Mutex<>>
so the future can remove itself from the collectionBoth strategies look overly complicated and have large overhead compared to a visitor over a collection we already have.
Another thing to note: both strategies actually represent pub-sub kind of pattern. Which would be useful for futures on its own. But presumably, it will always have additional overhead.
What do you think?
The text was updated successfully, but these errors were encountered: