public int size() {
        // Read consumer first, this is important because if the producer is node is 'older' than the consumer
        // the consumer may overtake it (consume past it) invalidating the 'snapshot' notion of size.
        final Node stub = this.stub;
        Node chaserNode = lvConsumerNode();
        if (chaserNode == stub) {
            chaserNode = chaserNode.getNext();
        }

        final Node producerNode = lvProducerNode();
        int size = 0;
        // must chase the nodes all the way to the producer node, but there's no need to count beyond expected head.
        while (chaserNode != null && chaserNode != stub &&
               size < Integer.MAX_VALUE) // stop at max int
        {
            if (chaserNode == producerNode) {
                return size + 1;
            }
            chaserNode = chaserNode.getNext();
            size++;
        }
        return size;
    }
This is an O(n) operation as we run through all the nodes and count them.<br>
The accuracy of the value returned by this method is subject to races with producer/consumer threads. In
particular when racing with the consumer thread this method may under estimate the size.<br>
Note that passing nodes between queues, or concurrent requeuing of nodes can cause this method to return strange
values.
jctools-experimental/src/main/java/org/jctools/queues/intrusive/MpscIntrusiveLinkedQueue.java