presto-main/src/main/java/io/prestosql/dispatcher/QueuedStatementResource.java/QueuedStatementResource/QueuedStatementResource
class QueuedStatementResource:    @Inject
    public QueuedStatementResource(
            DispatcherConfig dispatcherConfig,
            DispatchManager dispatchManager,
            DispatchExecutor executor)
    {
        requireNonNull(dispatcherConfig, "dispatcherConfig is null");
        this.forwardedHeaderSupport = dispatcherConfig.getForwardedHeaderSupport();
        this.dispatchManager = requireNonNull(dispatchManager, "dispatchManager is null");

        requireNonNull(dispatchManager, "dispatchManager is null");
        this.responseExecutor = requireNonNull(executor, "responseExecutor is null").getExecutor();
        this.timeoutExecutor = requireNonNull(executor, "timeoutExecutor is null").getScheduledExecutor();

        queryPurger.scheduleWithFixedDelay(
                () -> {
                    try {
                        // snapshot the queries before checking states to avoid registration race
                        for (Entry<QueryId, Query> entry : ImmutableSet.copyOf(queries.entrySet())) {
                            if (!entry.getValue().isSubmissionFinished()) {
                                continue;
                            }

                            // forget about this query if the query manager is no longer tracking it
                            if (!dispatchManager.isQueryRegistered(entry.getKey())) {
                                queries.remove(entry.getKey());
                            }
                        }
                    }
                    catch (Throwable e) {
                        log.warn(e, "Error removing old queries");
                    }
                },
                200,
                200,
                MILLISECONDS);
    }