@Override
    public boolean shouldWait() {
        RingbufferContainer ringbuffer = getRingBufferContainerOrNull();
        if (ringbuffer == null) {
            return true;
        }
        if (ringbuffer.isTooLargeSequence(sequence) || ringbuffer.isStaleSequence(sequence)) {
            //no need to wait, let the operation continue and fail in beforeRun
            return false;
        }
        // the sequence is not readable
        return sequence == ringbuffer.tailSequence() + 1;
    }
@Test
    public void whenBeforeHead() {
        ringbuffer.add("item1");
        ringbuffer.add("item2");
        ringbuffer.add("item3");

        long oldhead = ringbuffer.headSequence();
        ringbufferContainer.setHeadSequence(ringbufferContainer.tailSequence());

        ReadOneOperation op = getReadOneOperation(oldhead);

        op.shouldWait();
        assertThrows(StaleSequenceException.class, op::beforeRun);
    }