-
Notifications
You must be signed in to change notification settings - Fork 418
Event potential concurrency issues #5
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
Event#wait policy changed with a ConditionVariable Event#set and Event#reset changed to support the new policy Event general refactor
…by thread that posted them added: ImmediateExecutor specs future_spec, context fulfillment, changed to use ImmediateExecutor, so it can run faster
I made a noob mistake, the second commit was for another pull request... |
I apologize for not looking at this pull request earlier. The past several days have been very busy both at home and at work. I greatly appreciate your help. I don't entirely follow your last comment. Is this PR ready to go or are you still working on the refactoring? |
This PR is ready, in the next days I'm going to improve some other classes and refactor some other tests. |
@mutex.synchronize do | ||
return true if @set |
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.
Interesting. I expected this to raise a LocalJumpError, which is the normal case when using return within a block. But I've tried it in several version of MRI and it works. So I've learned a new trick with Mutex.
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.
I think return always works when there's a method context somewhere up in the stack.
Thank you for the time and effort you have spent on this. The reason I didn't synchronize the |
Event potential concurrency issues
Event class has some potential concurrency issues.
Event#set?
was not synchronized, causing inconsistent visibility under happens-before based memory model (like JRuby and Rubinius)Event#wait
was using an array to store enqueued threads andEvent#set
woke up them: aConditionVariable
is best suited in those cases and solves some check-then-act issues of the original versionAll test are still passing