presto-main/src/main/java/io/prestosql/execution/TaskStateMachine.java/TaskStateMachine/transitionToDoneState
class TaskStateMachine:    private void transitionToDoneState(TaskState doneState)
    {
        requireNonNull(doneState, "doneState is null");
        checkArgument(doneState.isDone(), "doneState %s is not a done state", doneState);

        taskState.setIf(doneState, currentState -> !currentState.isDone());
    }