Skip to content

Commit

Permalink
Fix blocking in SizedQueue#push
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jan 3, 2024
1 parent 4278f07 commit 18432dc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/src/main/java/org/jruby/ext/thread/SizedQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,16 @@ public IRubyObject push(ThreadContext context, final IRubyObject arg0) {
}

@JRubyMethod(name = {"push", "<<", "enq"})
public IRubyObject push(ThreadContext context, final IRubyObject arg0, final IRubyObject arg1) {
public IRubyObject push(ThreadContext context, final IRubyObject arg0, final IRubyObject nonblock) {
initializedCheck();

boolean should_block = arg1.isTrue();

try {
return context.getThread().executeTaskBlocking(context, arg0, should_block ? blockingPushTask : nonblockingPushTask);
RubyThread thread = context.getThread();
if (nonblock.isTrue()) {
return thread.executeTask(context, arg0, nonblockingPushTask);
} else {
return thread.executeTaskBlocking(context, arg0, blockingPushTask);
}
} catch (InterruptedException ie) {
throw createInterruptedError(context, "push");
}
Expand Down

0 comments on commit 18432dc

Please sign in to comment.