Skip to content

Commit

Permalink
Don't lock uninterruptibly. #4261
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Nov 2, 2016
1 parent 223cbd5 commit 2501c07
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions core/src/main/java/org/jruby/ext/thread/Mutex.java
Expand Up @@ -33,6 +33,7 @@
import org.jruby.RubyBoolean;
import org.jruby.RubyClass;
import org.jruby.RubyObject;
import org.jruby.RubyThread;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.Block;
Expand Down Expand Up @@ -84,17 +85,13 @@ public RubyBoolean try_lock(ThreadContext context) {

@JRubyMethod
public IRubyObject lock(ThreadContext context) {
RubyThread thread = context.getThread();
try {
context.getThread().enterSleep();
try {
checkRelocking(context);
context.getThread().lockInterruptibly(lock);
} catch (InterruptedException ex) {
context.pollThreadEvents();
throw context.runtime.newConcurrencyError("interrupted waiting for mutex");
}
thread.enterSleep();
checkRelocking(context);
thread.lock(lock);
} finally {
context.getThread().exitSleep();
thread.exitSleep();
}
return this;
}
Expand Down

0 comments on commit 2501c07

Please sign in to comment.