Skip to content

Commit d2e5bfd

Browse files
committed
Cleanup Queue#pop
1 parent be00a88 commit d2e5bfd

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/main/java/org/truffleruby/core/queue/QueueNodes.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ private Object doPop(UnsizedQueue queue) {
9393
}
9494

9595
@Specialization(guards = "!nonBlocking")
96-
protected Object popBlocking(RubyQueue self, boolean nonBlocking, long timeoutMilliseconds,
97-
@Exclusive @Cached InlinedBranchProfile closedProfile) {
96+
protected Object popBlocking(RubyQueue self, boolean nonBlocking, long timeoutMilliseconds) {
9897
final UnsizedQueue queue = self.queue;
9998
final long deadline = System.currentTimeMillis() + timeoutMilliseconds;
10099

101-
var result = getContext().getThreadManager().runUntilResult(this, () -> {
100+
return getContext().getThreadManager().runUntilResult(this, () -> {
102101
final long currentTimeout = deadline - System.currentTimeMillis();
103102
final Object value;
104103

@@ -108,18 +107,12 @@ protected Object popBlocking(RubyQueue self, boolean nonBlocking, long timeoutMi
108107
value = queue.poll();
109108
}
110109

111-
if (value == UnsizedQueue.CLOSED) {
112-
closedProfile.enter(this);
110+
if (value == UnsizedQueue.CLOSED || value == null) {
113111
return nil;
114112
} else {
115113
return value;
116114
}
117115
});
118-
119-
if (result == null) {
120-
return nil;
121-
}
122-
return result;
123116
}
124117

125118
@Specialization(guards = "nonBlocking")

0 commit comments

Comments
 (0)