@Override
    public void drain(Consumer<E> c, WaitStrategy w, ExitCondition exit)
    {
        final AtomicReferenceArray<E> buffer = this.buffer;
        final long mask = this.mask;
        long consumerPosition = lvConsumerPosition();

        int counter = 0;
        while (exit.keepRunning())
        {
            for (int i = 0; i < 4096; i++)
            {
                final int offset = calcElementOffset(consumerPosition, mask);
                final E e = buffer.get(offset);// LoadLoad
                if (null == e)
                {
                    counter = w.idle(counter);
                    continue;
                }
                consumerPosition++;
                counter = 0;
                //a plain store would be enough
                buffer.lazySet(offset, null);
                soConsumerPosition(consumerPosition); // ordered store -> atomic and ordered for size()
                c.accept(e);
            }
        }
    }
NOTE: This class was automatically generated by org.jctools.queues.atomic.JavaParsingAtomicArrayQueueGenerator
which can found in the jctools-build module. The original source file is MpscArrayQueue.java.
jctools-experimental/src/main/java/org/jctools/queues/atomic/MpscRelaxedAtomicArrayQueue.java