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

Return to interruptible lock acquisition in Mutex. #5683

Merged
merged 8 commits into from Apr 10, 2019

Conversation

@headius
Copy link
Member

@headius headius commented Apr 9, 2019

Fixes #5476.

@headius headius added this to the JRuby 9.2.8.0 milestone Apr 9, 2019
headius added 3 commits Apr 9, 2019
Fixes jruby#5476.

This reverts the original change from jruby#4261 that disabled lock
interrupts, and uses Task logic from RubyThread to handle the
interrupting properly.
This better models the way MRI uses the Mutex. Rather than
directly doing the unlock, sleep, lock steps, this version just
adds the thread to a listeners queue and asks the mutex to sleep.
This allows us to reuse the sleep logic already in Mutex, which
now properly defers to RubyThread methods to do its own unlock,
sleep, lock cycle. This centralizes all of the key Mutex behaviors
in RubyThread so they can be properly boxed with thread status
changes like "sleep".

This also fixes jruby#5476 by restoring full interruptibility to Mutex
contended lock calls. Both interrupts from Java and from Ruby will
wake the thread. This returns us to matching MRI's Mutex lock
interrupt behavior.
@headius headius force-pushed the java_interruptible_mutex branch from d6146cb to ed97131 Apr 10, 2019
headius added 5 commits Apr 10, 2019
* Move remaining non-waiter logic to a sleep dyncall, as in MRI.
* Restore deprecated wait_ruby with [] args.
* Arity split #wait all the way through to avoid nil coercion
  error in arity-split Mutex#sleep.
* Remove waiters while interrupting in #broadcast.
* Properly unify Mutex#sleep arities to match CRuby behavior.
* Unify ConditionVariable#wait_ruby logic again.
@headius
Copy link
Member Author

@headius headius commented Apr 10, 2019

Going ahead with this since it's nice and green, mostly deletes code, and matches CRuby behavior much more closely now.

Loading

@headius headius merged commit 7c9fa26 into jruby:master Apr 10, 2019
2 checks passed
Loading
@headius headius deleted the java_interruptible_mutex branch Apr 10, 2019
@kares
Copy link
Member

@kares kares commented Apr 11, 2019

very nice work, indeed

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants