@Override
        public int consume(ConsumerFunction<E> consumer, int batchSize) {
            final long[] sBuffer = this.sequenceBuffer;
            final E[] eBuffer = this.buffer;
            final long mask = this.mask;
            long tDelta;
            long currIndex;
            long targetIndex;
            currIndex = lvConsumerIndex();// LoadLoad
            targetIndex = currIndex + batchSize - 1;
            final long tsOffset = calcSequenceOffset(targetIndex, mask);
            tDelta = lvSequence(sBuffer, tsOffset) - (targetIndex + 1);

            if (tDelta == 0) {
                // can now consume all elements
                for (int i = 0; i < batchSize; i++) {
                    // The 'availability' of the target slot is not indicative of the 'availability' of every slot up to
                    // it. We have to consume all the elements now that we claimed the slots, so if they are not visible
                    // we must block.
                    long eDelta;
                    long sOffset;
                    do {
                        sOffset = calcSequenceOffset(currIndex, mask);
                        eDelta = lvSequence(sBuffer, sOffset) - (currIndex + 1);
                    } while (eDelta != 0);
                    E e = consumeElement(sBuffer, eBuffer, mask, currIndex++, sOffset);
                    consumer.consume(e);
                }
                return batchSize;
            }
            // bugger, queue is either:
            // (a) empty
            // (b) has less than batchSize elements
            // (c) slot at batch target is unavailable
            // we take the easy way out and weakPoll through this case
            int i = 0;
            for (; i < batchSize; i++) {
                final E e = weakPoll(sBuffer, eBuffer, mask);
                if (e == null) {
                    break;
                }
                consumer.consume(e);
            }
            return i;
        }
{@inheritDoc}
<p>
Because return null indicates queue is empty we cannot simply rely on next element visibility for poll and
must test producer index when next element is not visible.
jctools-experimental/src/main/java/org/jctools/queues/alt/MpscArrayConcurrentQueue.java