concurrency: `tokio::select` vs. `futures::select`
fw-immunant opened this issue · 1 comments
Currently when talking about combining futures, we introduce the futures::join
macro and futures::join_all
function, then tokio::select
. But there is also a select
macro in the futures library itself, though it has slightly different semantics and requirements: https://stackoverflow.com/questions/60811657/what-is-the-difference-between-futuresselect-and-tokioselect
In particular, the futures
version requires futures to implement the FusedFuture
trait and accesses them by mutable reference while the tokio
variant moves futures (so users may instead pass &mut f
) and does not require fusing.
We should at least mention the existence of the non-Tokio version so things don't seem so magical.
This is a good point! And perhaps the higher-level takeaway is that async Rust, while usable in production, is still in the "few ways to do it, seeing what's best" phase, and further stabilization will eventually select one preferred way to do it.