Package com.squareup.okhttp
Class Dispatcher
- java.lang.Object
-
- com.squareup.okhttp.Dispatcher
-
public final class Dispatcher extends Object
Policy on when async requests are executed.Each dispatcher uses an
ExecutorServiceto run calls internally. If you supply your own executor, it should be able to run the configured maximum number of calls concurrently.
-
-
Constructor Summary
Constructors Constructor Description Dispatcher()Dispatcher(ExecutorService executorService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel(Object tag)Cancel all calls with the tagtag.ExecutorServicegetExecutorService()intgetMaxRequests()intgetMaxRequestsPerHost()intgetQueuedCallCount()intgetRunningCallCount()voidsetMaxRequests(int maxRequests)Set the maximum number of requests to execute concurrently.voidsetMaxRequestsPerHost(int maxRequestsPerHost)Set the maximum number of requests for each host to execute concurrently.
-
-
-
Constructor Detail
-
Dispatcher
public Dispatcher(ExecutorService executorService)
-
Dispatcher
public Dispatcher()
-
-
Method Detail
-
getExecutorService
public ExecutorService getExecutorService()
-
setMaxRequests
public void setMaxRequests(int maxRequests)
Set the maximum number of requests to execute concurrently. Above this requests queue in memory, waiting for the running calls to complete.If more than
maxRequestsrequests are in flight when this is invoked, those requests will remain in flight.
-
getMaxRequests
public int getMaxRequests()
-
setMaxRequestsPerHost
public void setMaxRequestsPerHost(int maxRequestsPerHost)
Set 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.If more than
maxRequestsPerHostrequests are in flight when this is invoked, those requests will remain in flight.
-
getMaxRequestsPerHost
public int getMaxRequestsPerHost()
-
cancel
public void cancel(Object tag)
Cancel all calls with the tagtag.
-
getRunningCallCount
public int getRunningCallCount()
-
getQueuedCallCount
public int getQueuedCallCount()
-
-