src/main/java/io/reactivex/internal/queue/MpscLinkedQueue.java
@Nullable
    @Override
    public T poll() {
        LinkedQueueNode<T> currConsumerNode = lpConsumerNode(); // don't load twice, it's alright
        LinkedQueueNode<T> nextNode = currConsumerNode.lvNext();
        if (nextNode != null) {
            // we have to null out the value because we are going to hang on to the node
            final T nextValue = nextNode.getAndNullValue();
            spConsumerNode(nextNode);
            return nextValue;
        }
        else if (currConsumerNode != lvProducerNode()) {
            // spin, we are no longer wait free
            while ((nextNode = currConsumerNode.lvNext()) == null) { } // NOPMD
            // got the next node...

            // we have to null out the value because we are going to hang on to the node
            final T nextValue = nextNode.getAndNullValue();
            spConsumerNode(nextNode);
            return nextValue;
        }
        return null;
    }
@Nullable
    @Override
    public T poll() {
        LinkedQueueNode<T> currConsumerNode = lpConsumerNode(); // don't load twice, it's alright
        LinkedQueueNode<T> nextNode = currConsumerNode.lvNext();
        if (nextNode != null) {
            // we have to null out the value because we are going to hang on to the node
            final T nextValue = nextNode.getAndNullValue();
            spConsumerNode(nextNode);
            return nextValue;
        }
        else if (currConsumerNode != lvProducerNode()) {
            // spin, we are no longer wait free
            while ((nextNode = currConsumerNode.lvNext()) == null) { } // NOPMD
            // got the next node...

            // we have to null out the value because we are going to hang on to the node
            final T nextValue = nextNode.getAndNullValue();
            spConsumerNode(nextNode);
            return nextValue;
        }
        return null;
    }
@ Nullable @ Override public T poll ( ) { LinkedQueueNode < T > currConsumerNode = lpConsumerNode ( ) ; // don't load twice, it's alright LinkedQueueNode < T > nextNode = currConsumerNode . lvNext ( ) ; if ( nextNode != null ) { // we have to null out the value because we are going to hang on to the node final T nextValue = nextNode . getAndNullValue ( ) ; spConsumerNode ( nextNode ) ; return nextValue ; } else if ( currConsumerNode != lvProducerNode ( ) ) { // spin, we are no longer wait free while ( ( nextNode = currConsumerNode . lvNext ( ) ) == null ) { } // NOPMD // got the next node... // we have to null out the value because we are going to hang on to the node final T nextValue = nextNode . getAndNullValue ( ) ; spConsumerNode ( nextNode ) ; return nextValue ; } return null ; }
{@inheritDoc} <br>
<p>
IMPLEMENTATION NOTES:<br>
Poll is allowed from a SINGLE thread.<br>
Poll reads the next node from the consumerNode and:
<ol>
<li>If it is null, the queue is assumed empty (though it might not be).
<li>If it is not null set it as the consumer node and return it's now evacuated value.
</ol>
This means the consumerNode.value is always null, which is also the starting point for the queue. Because null
values are not allowed to be offered this is the only node with it's value set to null at any one time.

@see java.util.Queue#poll()
{ @inheritDoc } <br > <p > IMPLEMENTATION NOTES : <br > Poll is allowed from a SINGLE thread . <br > Poll reads the next node from the consumerNode and : <ol > <li > If it is null the queue is assumed empty ( though it might not be ) . <li > If it is not null set it as the consumer node and return it s now evacuated value . < / ol > This means the consumerNode . value is always null which is also the starting point for the queue . Because null values are not allowed to be offered this is the only node with it s value set to null at any one time .