Blog Post: Futures Concurrency III

Hey all, I've published the third installment in my "async concurrency" series of blog posts, this time on the "process concurrently, yield sequentially" (for lack of a better name) mode of concurrency. I cover how the select! macro implements this mode of concurrency, cover the issues specific to the select!, and show an alternative non-macro API which enables this mode of concurrency to be used.

It's a rather long read, and is closer to "reference guide" than "tutorial". But I hope it'll be helpful for people looking to write (concurrent) async code, and help inform the design of the APIs we provide via the language and library. Thanks!

7 Likes
  1. How often does merge -ing futures come up in practice?

Yeah, having a .once() on Future that explicitly reframes it as an AsyncIterator seems sufficient here: much like Stream::collect collects a future for "stream has emitted all its items".

And honestly, I'd expect

(async {
    sleep(dur!(1 sec).await);
    [1,2,3]
}).into_async_iter()

to be a stream that waits the future and then yields 1 2 3 as individual items, not as one array. (For that matter, it makes sense for Iterator to have a trivial IntoAsyncIterator that just never returns Poll::Pending)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.