Skip to content

Commit

Permalink
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core/src/main/java/org/jruby/ext/thread/Queue.java
Original file line number Diff line number Diff line change
@@ -122,6 +122,7 @@ public IRubyObject pop(ThreadContext context) {
try {
return context.getThread().executeTask(context, this, BLOCKING_POP_TASK);
} catch (InterruptedException ie) {
// FIXME: is this the right thing to do?
throw context.runtime.newThreadError("interrupted in " + getMetaClass().getName() + "#pop");
}
}
@@ -137,11 +138,12 @@ public IRubyObject pop(ThreadContext context, IRubyObject arg0) {

@JRubyMethod(name = {"push", "<<", "enq"})
public IRubyObject push(ThreadContext context, IRubyObject value) {
if (closed) {
raiseClosedError(context);
}
lock.lock();
try {
if (closed) {
raiseClosedError(context);
}

getQue().add(value);
popCond.signal();
} finally {
@@ -221,9 +223,6 @@ protected IRubyObject popBlocking(ThreadContext context) throws InterruptedExcep
return context.nil;
}
else {
assert(getQue().size() == 0);
assert(!closed);

popCond.await();
}
}

0 comments on commit c75accf

Please sign in to comment.