-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
replace channel-based timers with a recv_timeout method #11223
Comments
This is not the only reason that channel-based timers exist, and I don't think that they should be removed as part of this issue. I believe this issue should be about adding a Some uses for channel-based timers:
|
That's why the native sleeping API is divided into let mut abstime = monotonic();
loop {
abstime.add_second(1);
abstime.sleep_until();
println("foo")
}
It would be more efficient to have a timeout parameter to
Having all of these inter-dependencies makes the standard library less useful to someone who needs more than it offers. If you need multiple-producer/multiple-consumer channels, bounded channels or just different performance characteristics (contiguous memory) then you're sold out of luck. |
Accepted for 1.0, P-backcompat-libs. |
I do feel a little uncomfortable about the timer API being coupled to channels, but I'm thinking we can let stability attributes deal with this, and if the 1.0 timer API isn't the best it's not the end of the world. The biggest concern with leaving them together is that it makes refactoring channels and I/O into different crates difficult or impossible. Nominating for removal from milestone. |
Leaving at P-backcompat-libs, but removing from 1.0 milestone |
Channel based timers are part of |
Fix issue 11223: add check for identical guards in lint `match_same_arms` fixes rust-lang#11223 In the current `match_same_arms` implementation, if arms have guards, they are considered different. This commit adds equality checking for guards: arms are now considered equivalent only when they either both have no guards or their guards are identical. The portion responsible for checking guard equality is refactored to reuse the existing code for checking body equality. This is abstracted into a function called `check_eq_with_pat`. To optimize performance, `check_same_guard` and `check_same_body` here use closures for lazy evaluation, ensuring that the calculation is only performed when `!(backwards_blocking_idxs...)` is true. changelog: [`match_same_arms`]: Add check for identical guards
If it's done directly on channel types, it will be easier to use because it won't require the caller to worry about a pattern like
select
.For the 1:1 case, this would just be a call to
pthread_cond_timedwait
after initializing the condition variable withCLOCK_MONOTONIC
as the clock.Windows condition variables expose a similar method taking a relative time, but there's no way to wait again for the remaining time after a spurious wake-up. If this is important, we can build the functionality on top of the win32 API or use another implementation.
For M:N threading it can either keep doing what it does now behind the scenes, or use an efficient timer/condvar contraption too.
The text was updated successfully, but these errors were encountered: