presto-hive/src/main/java/io/prestosql/plugin/hive/util/ResumableTasks.java/ResumableTasks/run
class ResumableTasks:    public static ListenableFuture<Void> submit(Executor executor, ResumableTask task)
    {
        SettableFuture<Void> completionFuture = SettableFuture.create();
        executor.execute(new Runnable()
        {
            @Override
            public void run()
            {
                ResumableTask.TaskStatus status;
                try {
                    status = task.process();
                }
                catch (Throwable t) {
                    log.error(t, "ResumableTask completed exceptionally");
                    completionFuture.setException(t);
                    return;
                }

                if (status.isFinished()) {
                    completionFuture.set(null);
                    return;
                }

                // if task is not complete, schedule it it to run again when the future finishes
                status.getContinuationFuture().addListener(this, executor);
            }
        });
        return completionFuture;
    }