-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Provide a select_biased! macro #2181
Comments
I'm not sure adding a new macro makes sense, but we could add a |
I agree that there are use cases for controlling the poll order. However, I don't love the idea of having a separate macro for the use case. I wonder if there is a way to work this into the |
Henlo. I was having this whole experience today, and here is what I learned: let start = $crate::macros::support::thread_rng_n(BRANCHES);
for i in 0..BRANCHES {
let branch;
#[allow(clippy::modulo_one)]
{
branch = (start + i) % BRANCHES;
} I propose that we move all of the current implementation into a (possibly public? maybe later?) From there, we can reimplement Regarding special annotations on the arms, the current for-based design already doesn't allow patterns like "poll Declaration order is a well-understood pattern, and crazy patterns can be achieved with nested |
Similar to `futures::select_biased!`, it is sometimes beneficial to provide developers with strict control over the polling order of futures. Most of the time, the fairness guarantees that `select!` provides through RNG can be thought out by a careful developer to ensure that no one future will monopolize all of the CPU time. In exchange for this, the developer gets a performance boost as they do not need to spend time generating endless random numbers. Fixes: tokio-rs#2181
Since #2152 introduced the
select!
macro, is it possible to provide aselect_biased!
macro as well, similar to the futures-rs one?It's useful in cases where the polling order does matter, such as when you need to guarantee dropping a future at the next yield point.
The text was updated successfully, but these errors were encountered: