Skip to content
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

Implement recv_timeout for std::comm *Port implementations #9194

Closed
wants to merge 2 commits into from

Conversation

flaper87
Copy link
Contributor

Fixes #3015

@alexcrichton
Copy link
Member

I'm actually fairly opposed to this change. Polling for synchronization primitives in my opinion is the wrong way to implement timeouts. If you think about the polling intervals, it turns out that polling is wrong 100% of the time. Each time the poller decides to go to sleep, it should not have awoken. When the poller decides that the timeout is done, then it was too late, so every guess by the poller is "wrong" in a sense.

It looks like we don't currently have support for accurate timeouts in the libuv loop yet, so I'm ok with these functions existing in some form, but they should be extremely clear that they perform polling and not accurate timeouts. When I write code to have timeouts, I expect the library to have it implemented such that there is no polling and that timeouts occur in a timely fashion.

Especially in this implementation you could wait for up to a second waiting for an event to happen when in fact it already happens. In my opinion this extremely undesirable, especially from a core library perspective.

Could you explain a bit more why we think that this is the desired strategy to settle on now for timeouts? If this is purely an interim solution (blocked on one easy bug), then I think that it still shouldn't be added, and in the long run if we need some general rearchitecting it seems like we still shouldn't add timeouts in this form.

@alexcrichton
Copy link
Member

I've cancelled the build for now, I'd like to resolve some of my concerns first before letting this through bors.

@flaper87
Copy link
Contributor Author

@alexcrichton I agree with you 100% and that is the exact reason why #9195 was created. However, I thought that letting this patch land and then rewrite it after we figure out the state of select in Rust.

I'm not opposed to blocking this patch and letting it land after 0.8 release and if by that time we're already able to rewrite it then we can do that instead of letting this one land.

I do think we should let the functionality in, asap with the right NOTES / FIXME.

@alexcrichton
Copy link
Member

In my opinion, I feel that this an aspect of our primitives which should not be implemented until it's ready to be implemented. I don't think that select will be settled on soon (I could be wrong).

If we do implement this, it should certainly have poll somewhere in the function name and the documentation should be painfully clear that this is a "polling implementation" and will be followed by a real implementation once we're ready.

@alexcrichton
Copy link
Member

After a discussion on IRC, we've agreed to put this on hold until a few days before 0.8 is released. @flaper87 may have "real timeouts" by then, making this issue moot. If some more work is still required, we'll re-visit this request around that time.

@flaper87
Copy link
Contributor Author

@alexcrichton I rebased the branch and ran tests. Not sure I'll be able to implement the new stuff before 0.8 is released. Sorry about that, last week was very busy.

@@ -1 +1 @@
Subproject commit c9ffab392a39eb85f2f15ffc8d41e8c4f4397b8e
Subproject commit 08a3bd96ee6e1d141494f0014ede75d9871114c4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may have leaked in at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to get this merged for 0.8? As mentioned, I'm already working on
the new version based on Select.

@flaper87
Copy link
Contributor Author

@alexcrichton rebased and reverted the llvm commit.

@alexcrichton
Copy link
Member

ping @brson

@brson
Copy link
Contributor

brson commented Sep 25, 2013

I don't want to implement a recv_timeout function that uses polling. In general we have added to much to the new runtime already before it's stable. We can't keep piling up the debt.

@brson brson closed this Sep 25, 2013
@flaper87
Copy link
Contributor Author

@brson, As mentioned in my previous comments, I agree with this not being optimal, although the idea was to let the API land.

I'm already working on the new implementation, hopefully, I'll be able to commit it soon.
Thanks.

@flaper87 flaper87 deleted the issue/3015 branch September 25, 2013 07:29
@flaper87 flaper87 restored the issue/3015 branch September 25, 2013 07:30
@flaper87 flaper87 deleted the issue/3015 branch March 11, 2014 09:16
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 18, 2022
Fix example for `clippy::invalid_regex`

Close rust-lang#9194
changelog: previous example doesn't trigger lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add recv_timeout for pipes
3 participants