-
Notifications
You must be signed in to change notification settings - Fork 468
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
Please clarify the behavior of Parker #482
Comments
Asked as well on stack overflow: https://stackoverflow.com/questions/63543946/how-are-you-supposed-to-handle-a-spurious-wakeup-of-a-parker/63544651 I'm also confused by this, because my reading of the implementation is that (assuming atomics don't spuriously change value) there shouldn't be any possible spurious wakeups under the current implementation. |
It seems spurious wakeups never happen. :) The reason why the docs mention this is because Note that when we say that wakeups are 'spurious', that means they might happen sometimes but very rarely. In fact, so rarely that you don't need to worry about their performance implications. Usually, parking is done in a while loop and on spurious wakeup we just check whether the loop is done and park again if not. It's kind of similar to how we use I think the original idea behind saying that spurious wakeups are possible is that we might choose to switch to a different, more efficient implementation that does sometimes spuriously unpark, but in my opinion it is unlikely we'll ever change the implementation. So it's just a pessimistic disclaimer that ensures we're not stuck with the current implementation that doesn't spuriously unpark. Anyways, my opinion is that there's no point in keeping this disclaimer and we should just delete it from the docs. |
I have a pull request in progress to deal with this. Spurious wakeups actually are possible with timeout parks, because they never re-check the condition after the condition variable wait finishes. So I'm tying up some of that, and also adding a simple enum that reports whether a park ended due to a timeout or an unpark. I should have that up for review this week. |
Note: Once this issue closes, go update the Stack Overflow question and answer as well. |
Hi
I have some questions about the Parker type. The
park()
method explicitly mentions the following:Questions:
p.park()
, it might unblock and continue without having to directly callu.unpark()
?park()
to work reliably, what should be used instead? What's the point ofParker
if it's unreliable?Thanks for your time.
The text was updated successfully, but these errors were encountered: