google / google/comprehensive-rust

concurrency: `tokio::select` vs. `futures::select`

Open
#2,352 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
33.4k
Forks
2.1k
Avg merge
1d 3h
Merged PRs (30d)
10

Description

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`](https://docs.rs/futures/latest/futures/macro.select.html) 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.