Skip to content

Commit d51d3ff

Browse files
Revert "Refactor MpscLinkedQueue.poll"
This reverts commit b8582b9.
1 parent 43a7cf7 commit d51d3ff

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main/java/io/reactivex/rxjava3/internal/queue/MpscLinkedQueue.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,23 @@ public boolean offer(final T e) {
8787
public T poll() {
8888
LinkedQueueNode<T> currConsumerNode = lpConsumerNode(); // don't load twice, it's alright
8989
LinkedQueueNode<T> nextNode = currConsumerNode.lvNext();
90-
final T nextValue;
91-
if (nextNode == null && currConsumerNode == lvProducerNode()) {
92-
return null;
90+
if (nextNode != null) {
91+
// we have to null out the value because we are going to hang on to the node
92+
final T nextValue = nextNode.getAndNullValue();
93+
spConsumerNode(nextNode);
94+
return nextValue;
9395
}
94-
if (nextNode == null) {
96+
else if (currConsumerNode != lvProducerNode()) {
9597
// spin, we are no longer wait free
9698
while ((nextNode = currConsumerNode.lvNext()) == null) { } // NOPMD
9799
// got the next node...
100+
101+
// we have to null out the value because we are going to hang on to the node
102+
final T nextValue = nextNode.getAndNullValue();
103+
spConsumerNode(nextNode);
104+
return nextValue;
98105
}
99-
// we have to null out the value because we are going to hang on to the node
100-
nextValue = nextNode.getAndNullValue();
101-
spConsumerNode(nextNode);
102-
return nextValue;
106+
return null;
103107
}
104108

105109
@Override

0 commit comments

Comments
 (0)