private void dispatch() {
        try {
            while (breaker.state() != OPEN && ! destroyed.get()) {
                while ( ! isInExcess() && poll() && breaker.state() == CLOSED);

                if (breaker.state() == HALF_OPEN && reset.compareAndSet(false, true))
                    resettableCluster.reset();
                else if (breaker.state() == CLOSED)
                    reset.set(false);

                // Sleep when circuit is half-open, nap when queue is empty, or we are throttled.
                Thread.sleep(breaker.state() == HALF_OPEN ? 100 : 1);
            }
        }
        catch (Throwable t) {
            log.log(SEVERE, "Dispatch thread threw; shutting down", t);
        }
        destroy();
    }
Controls request execution and retries.

This class has all control flow for throttling and dispatching HTTP requests to an injected
HTTP {@link Cluster}, including error handling and retries through a {@link RetryStrategy},
a {@link CircuitBreaker} mechanism, and a {@link Throttler} for optimal load.

Dispatch to the provided {@link Cluster} is done by a single dispatch thread. If dispatch ever throws,
or the circuit breaker ever opens completely, the dispatch thread stops and all execution shuts down.
This is done through {@link #destroy()}, which when called also ensures all enqueued operations are
promptly completed, in addition to releasing any resources (threads, and in the provided cluster}.

@author jonmv
vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpRequestStrategy.java