Dispatcher

Policy on when async requests are executed.

Each dispatcher uses an ExecutorService to run calls internally. If you supply your own executor, it must accept new tasks while up to the configured maximum calls are already running. A pool sized exactly to maxRequests is not sufficient with a SynchronousQueue, because the dispatcher may submit the next call from a worker that has not yet returned to the queue. Prefer the default pattern (corePoolSize=0, maxPoolSize=Int.MAX_VALUE, SynchronousQueue), a bound of about 2 * maxRequests, or a queueing executor.

Constructors

Link copied to clipboard
constructor()
constructor(executorService: ExecutorService?)

Properties

Link copied to clipboard
Link copied to clipboard

A callback to be invoked each time the dispatcher becomes idle (when the number of running calls returns to zero).

Link copied to clipboard

The maximum number of requests to execute concurrently. Above this requests queue in memory, waiting for the running calls to complete.

Link copied to clipboard

The maximum number of requests for each host to execute concurrently. This limits requests by the URL's host name. Note that concurrent requests to a single IP address may still exceed this limit: multiple hostnames may share an IP address or be routed through the same HTTP proxy.

Functions

Link copied to clipboard
fun cancelAll()

Cancel all calls currently enqueued or executing. Includes calls executed both synchronously and asynchronously.

Link copied to clipboard
Link copied to clipboard

Returns a snapshot of the calls currently awaiting execution.

Link copied to clipboard
Link copied to clipboard

Returns a snapshot of the calls currently being executed.

Link copied to clipboard