presto-main/src/main/java/io/prestosql/execution/StateMachine.java/StateMachine/fireStateChanged
class StateMachine:    private void fireStateChanged(T newState, FutureStateChange<T> futureStateChange, List<StateChangeListener<T>> stateChangeListeners)
    {
        checkState(!Thread.holdsLock(lock), "Can not fire state change event while holding the lock");
        requireNonNull(newState, "newState is null");

        // always fire listener callbacks from a different thread
        safeExecute(() -> {
            checkState(!Thread.holdsLock(lock), "Can not notify while holding the lock");
            try {
                futureStateChange.complete(newState);
            }
            catch (Throwable e) {
                log.error(e, "Error setting future state for %s", name);
            }
            for (StateChangeListener<T> stateChangeListener : stateChangeListeners) {
                fireStateChangedListener(newState, stateChangeListener);
            }
        });
    }