-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Make UvTImer selectable and implement recv_timeout #9746
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
Conversation
@@ -24,6 +29,13 @@ pub fn sleep(msecs: u64) { | |||
timer.sleep(msecs) | |||
} | |||
|
|||
/// Sleep the current task for `msecs` milliseconds. | |||
pub fn sleep_uv(msecs: u64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different to normal sleep
? Can the difference please be documented?
(Also, I believe a goal for std::rt::io
is to be independent of the event loop that it is running on, so a function with a name like sleep_uv
seems like it would be exposing too many implementation details of the libuv
event loop. That said, I'm no expert on the RT, and I haven't looked at the implementations at all.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be removed, I added a comment in the UvTimer implementation of this method. It was part of some experiments I was doing, sorry for the confusion here, I'll get rid of it.
I have got this doing
|
Closing due to inactivity, and I also think that this may be superseded by #10083. We may still want a different form of selectability for timers, but we at least have some methods of using timers as ports now. |
Not sure this is already implemented, and I was going to get back to it. This PR is about implementing Select and SelectInner for the Timer, which will allow for blocking on recv up to N msecs and return when either the port receives a message or the timer expires. |
@flaper87 this branch is dead, more or less, due to age and the points @alexcrichton makes above. If we want to proceed, do it on a new PR. Thanks. |
@olsonjeffery yeah, just wanted to drop a comment explaining why I think it's not fully implemented! Will do it in a new PR! |
Fix ICE in `redundant_allocation` changelog: Fix ICE in `redundant_allocation` Closes rust-lang#9746, the original issue was fixed already, this gets the one in rust-lang/rust-clippy#9746 (comment)
NOTE This is not ready to be merged, it's a work in progress idea.
I'm looking for feedback on the
SelectInner
implementation for UvTimer. The idea I came up with is to have aselect_then
method that takes a callback and calls it right after starting the watcher. The reason why this is needed is that libuv IO has to happen within it's own scheduler and before switching back to the main scheduler the timer has to have completed or stopped.In
sleep_then
callback, users will be able to either deschedule the task themselves or sleep on multiple 'selectable' objects and wake up the task at the first event.Thoughts?
This is part of #3015