Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: aa27e405f101
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 19a76762e51f
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 23, 2015

  1. Make sure threads are actually waiting in Mutex specs

    * The thread can also have the status "sleep" while calling Mutex#lock.
    eregon committed Jul 23, 2015
    Copy the full SHA
    dee05a2 View commit details
  2. [Truffle] Queue#push on an unbounded queue is not a blocking operation.

    * Except if it there are Integer.MAX_VALUE elements in the queue.
    eregon committed Jul 23, 2015
    Copy the full SHA
    19a7676 View commit details
Showing with 5 additions and 8 deletions.
  1. +3 −0 spec/ruby/core/mutex/sleep_spec.rb
  2. +1 −0 spec/ruby/core/mutex/unlock_spec.rb
  3. +1 −8 truffle/src/main/java/org/jruby/truffle/nodes/core/QueueNodes.java
3 changes: 3 additions & 0 deletions spec/ruby/core/mutex/sleep_spec.rb
Original file line number Diff line number Diff line change
@@ -50,14 +50,17 @@

it "relocks the mutex when woken by an exception being raised" do
m = Mutex.new
locked = false
th = Thread.new do
m.lock
locked = true
begin
m.sleep
rescue Exception
m.locked?
end
end
Thread.pass until locked
Thread.pass while th.status and th.status != "sleep"
th.raise(Exception)
th.value.should be_true
1 change: 1 addition & 0 deletions spec/ruby/core/mutex/unlock_spec.rb
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
end

# avoid race on mutex.lock
Thread.pass until mutex.locked?
Thread.pass while th.status and th.status != "sleep"

lambda { mutex.unlock }.should raise_error(ThreadError)
Original file line number Diff line number Diff line change
@@ -77,14 +77,7 @@ public PushNode(RubyContext context, SourceSection sourceSection) {
public RubyBasicObject push(RubyBasicObject self, final Object value) {
final BlockingQueue<Object> queue = getQueue(self);

getContext().getThreadManager().runUntilResult(new BlockingAction<Boolean>() {
@Override
public Boolean block() throws InterruptedException {
queue.put(value);
return SUCCESS;
}
});

queue.add(value);
return self;
}