@SuppressWarnings("unchecked") private T newBufferPoll(AtomicReferenceArray<Object> nextBuffer, final long index, final int mask) { consumerBuffer = nextBuffer; final int offsetInNew = calcWrappedOffset(index, mask); final T n = (T) lvElement(nextBuffer, offsetInNew);// LoadLoad if (null != n) { soElement(nextBuffer, offsetInNew, null);// StoreStore soConsumerIndex(index + 1);// this ensures correctness on 32bit platforms } return n; }
@SuppressWarnings("unchecked") private T newBufferPoll(AtomicReferenceArray<Object> nextBuffer, final long index, final int mask) { consumerBuffer = nextBuffer; final int offsetInNew = calcWrappedOffset(index, mask); final T n = (T) lvElement(nextBuffer, offsetInNew);// LoadLoad if (null != n) { soElement(nextBuffer, offsetInNew, null);// StoreStore soConsumerIndex(index + 1);// this ensures correctness on 32bit platforms } return n; }
@SuppressWarnings("unchecked") private T newBufferPoll(AtomicReferenceArray<Object> nextBuffer, final long index, final int mask) { consumerBuffer = nextBuffer; final int offsetInNew = calcWrappedOffset(index, mask); final T n = (T) lvElement(nextBuffer, offsetInNew);// LoadLoad if (null != n) { soElement(nextBuffer, offsetInNew, null);// StoreStore soConsumerIndex(index + 1);// this ensures correctness on 32bit platforms } return n; }
@Nullable @SuppressWarnings("unchecked") public final T poll() { // local load of field to avoid repeated loads after volatile reads final AtomicReferenceArray<Object> buffer = consumerBuffer; final long index = lpConsumerIndex(); final int mask = consumerMask; final int offset = calcWrappedOffset(index, mask); final Object e = lvElement(buffer, offset);// LoadLoad boolean isNextBuffer = e == HAS_NEXT; if (null != e && !isNextBuffer) { soElement(buffer, offset, null);// StoreStore soConsumerIndex(index + 1);// this ensures correctness on 32bit platforms return (T) e; } else if (isNextBuffer) { return newBufferPoll(lvNext(buffer), index, mask); } return null; }
@Nullable @SuppressWarnings("unchecked") public final T poll() { // local load of field to avoid repeated loads after volatile reads final AtomicReferenceArray<Object> buffer = consumerBuffer; final long index = lpConsumerIndex(); final int mask = consumerMask; final int offset = calcWrappedOffset(index, mask); final Object e = lvElement(buffer, offset);// LoadLoad boolean isNextBuffer = e == HAS_NEXT; if (null != e && !isNextBuffer) { soElement(buffer, offset, null);// StoreStore soConsumerIndex(index + 1);// this ensures correctness on 32bit platforms return (T) e; } else if (isNextBuffer) { return newBufferPoll(lvNext(buffer), index, mask); } return null; }
@Nullable @SuppressWarnings("unchecked") public final T poll() { // local load of field to avoid repeated loads after volatile reads final AtomicReferenceArray<Object> buffer = consumerBuffer; final long index = lpConsumerIndex(); final int mask = consumerMask; final int offset = calcWrappedOffset(index, mask); final Object e = lvElement(buffer, offset);// LoadLoad boolean isNextBuffer = e == HAS_NEXT; if (null != e && !isNextBuffer) { soElement(buffer, offset, null);// StoreStore soConsumerIndex(index + 1);// this ensures correctness on 32bit platforms return (T) e; } else if (isNextBuffer) { return newBufferPoll(lvNext(buffer), index, mask); } return null; }