public AbstractMpscLinkedQueue() { producerNode = new AtomicReference<LinkedQueueNode<T>>(); consumerNode = new AtomicReference<LinkedQueueNode<T>>(); LinkedQueueNode<T> node = new LinkedQueueNode<T>(); spConsumerNode(node); xchgProducerNode(node);// this ensures correct construction: StoreLoad }
public AbstractMpscLinkedQueue() { producerNode = new AtomicReference<LinkedQueueNode<T>>(); consumerNode = new AtomicReference<LinkedQueueNode<T>>(); LinkedQueueNode<T> node = new LinkedQueueNode<T>(); spConsumerNode(node); xchgProducerNode(node);// this ensures correct construction: StoreLoad }
public AbstractMpscLinkedQueue() { producerNode = new AtomicReference<LinkedQueueNode<T>>(); consumerNode = new AtomicReference<LinkedQueueNode<T>>(); LinkedQueueNode<T> node = new LinkedQueueNode<T>(); spConsumerNode(node); xchgProducerNode(node);// this ensures correct construction: StoreLoad }
@Nullable public final 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 public final 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 public final 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; }