diff --git a/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddArrayQueue.java b/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddArrayQueue.java index e4687909..786919d9 100644 --- a/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddArrayQueue.java +++ b/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddArrayQueue.java @@ -308,7 +308,7 @@ final R producerChunkForIndex( { // prev cannot be null, because the consumer cannot null it without consuming the element for which we are // trying to get the chunk. - currentChunk = currentChunk.lvPrev(); + currentChunk = currentChunk.lpPrev(); assert currentChunk != null; } assert currentChunk.lvIndex() == requiredChunkIndex; @@ -355,7 +355,7 @@ private R newOrPooledChunk(R prevChunk, long nextChunkIndex) { // single-writer: prevChunk::index == nextChunkIndex is protecting it assert newChunk.lvIndex() < prevChunk.lvIndex(); - newChunk.soPrev(prevChunk); + newChunk.spPrev(prevChunk); // index set is releasing prev, allowing other pending offers to continue newChunk.soIndex(nextChunkIndex); } @@ -374,7 +374,7 @@ final void moveToNextConsumerChunk(R cChunk, R next) { // avoid GC nepotism cChunk.soNext(null); - next.soPrev(null); + next.spPrev(null); // no need to cChunk.soIndex(NOT_USED) if (cChunk.isPooled()) { diff --git a/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddChunk.java b/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddChunk.java index 13625779..3b60d8f1 100644 --- a/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddChunk.java +++ b/jctools-core/src/main/java/org/jctools/queues/MpUnboundedXaddChunk.java @@ -11,21 +11,20 @@ class MpUnboundedXaddChunk { final static int NOT_USED = -1; - private static final long PREV_OFFSET = fieldOffset(MpUnboundedXaddChunk.class, "prev"); private static final long NEXT_OFFSET = fieldOffset(MpUnboundedXaddChunk.class, "next"); private static final long INDEX_OFFSET = fieldOffset(MpUnboundedXaddChunk.class, "index"); private final boolean pooled; private final E[] buffer; - private volatile R prev; + private R prev; private volatile long index; private volatile R next; MpUnboundedXaddChunk(long index, R prev, int size, boolean pooled) { buffer = allocateRefArray(size); // next is null - soPrev(prev); + spPrev(prev); spIndex(index); this.pooled = pooled; } @@ -60,14 +59,14 @@ final void soNext(R value) UNSAFE.putOrderedObject(this, NEXT_OFFSET, value); } - final R lvPrev() + final R lpPrev() { - return prev; + return this.prev; } - final void soPrev(R value) + final void spPrev(R value) { - UNSAFE.putObject(this, PREV_OFFSET, value); + this.prev = value; } final void soElement(int index, E e)