nrc / portable-interoperable

Async fundamentals initiative: portable and interoperable
Apache License 2.0
75 stars 0 forks source link

select macro #6

Open nrc opened 2 years ago

nrc commented 2 years ago

Both Tokio and futures-rs provide a select macro, they provide roughly the same functionality but have different implementations, APIs (in the mini-language supported), and constraints (notably, futures-rs requires futures to be fused).

There seems to be a lot of demand for select (and it is runtime-agnostic), so it is a good candidate for inclusion in std, rather than it being supplied with a runtime. However, there seem to be a lot of questions:

Note that since it is a macro, select is likely to be insta-stable. Also note that if we don't require fusing in select, then there is probably no reason for FusedFuture to exist at all.

Previous discussion:

danielhenrymantilla commented 2 years ago

A tiny improvement w.r.t. footguns could be to:

yoshuawuyts commented 2 years ago

I wrote an in-depth analysis of select! {} in my "Futures Concurrency III: Select" blog post. To summarize my conclusion: the select! {} is difficult to use, would be hard to bring bring into the stdlib or language, and the same modes of concurrency can be exposed through alternative APIs. The AsyncIterator::merge family of APIs seems like the most promising alternative, and I would recommend we shift our focus to exploring those further instead.