Return to interruptible lock acquisition in Mutex.#5683
Merged
headius merged 8 commits intojruby:masterfrom Apr 10, 2019
Merged
Return to interruptible lock acquisition in Mutex.#5683headius merged 8 commits intojruby:masterfrom
headius merged 8 commits intojruby:masterfrom
Conversation
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.
d6146cb to
ed97131
Compare
* 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.
Member
Author
|
Going ahead with this since it's nice and green, mostly deletes code, and matches CRuby behavior much more closely now. |
Member
|
very nice work, indeed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5476.