@Override
    public void updateState() {
        lock.lock();
        try {
            StreamPreState state = stateHolder.getState();
            try {
                state.newAndEveryStateEventList.sort(eventTimeComparator);
                state.pendingStateEventList.addAll(state.newAndEveryStateEventList);
                state.newAndEveryStateEventList.clear();
            } finally {
                stateHolder.returnState(state);
            }

        } finally {
            lock.unlock();
        }
    }
Set as the last element of the processor chain

@param processor Last processor in the chain
modules/siddhi-core/src/main/java/io/siddhi/core/query/input/stream/state/StreamPreStateProcessor.java