-
Notifications
You must be signed in to change notification settings - Fork 15
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
Use optimistic behavior in Barrier #952
Conversation
This eliminates one lock acquisition during Barrier and implements a double-check pattern, which makes the Barrier routine significantly faster in cases where the queue is empty.
Makes sense to me. Shouldn't the |
Actually that's a good point. The difference in behavior is going to have to be fixed another way. In fact, if the count is zero, I still want to block for a single element from the queue to be dispatched. The reason is that the |
9169062
to
c0775e0
Compare
Doesn't it still save computation if you keep the check on line 297? And with this new logic, if timeout is zero but count is not, then shouldn't it still fail? |
Ah crap, yes that was the intention, I wrote it wrong. |
Also I can't keep that check. For the function to behave properly, I need to always pend that lambda to the queue and wait for the main thread to dispatch it, otherwise the timed |
Does the caller of Barrier know it's waiting for the thread to start? I imagine that that use case could be handled by the untimed Barrier instead, since the behavior is effectively untimed. Unless "timed" in this case means:
|
This class is used as the base class for In Autowiring, I try to use the following paradigm:
This is meant to parallel The untimed An general exception are cases where zero is specified for the timeout. In that case, we infer that the user does not actually want to wait for anything, and instead the call should be interpreted to be a check for the underlying condition rather than a desire to block for some condition to be true. |
Ok, that makes more sense. Thanks for the explanation. |
This eliminates one lock acquisition during Barrier and implements a double-check pattern, which makes the Barrier routine significantly faster in cases where the queue is empty.