类 Dispatcher
Each dispatcher uses an ExecutorService to run calls internally. If you supply your
own executor, it should be able to run the configured maximum number
of calls concurrently.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidCancel all calls currently enqueued or executing.intintReturns a snapshot of the calls currently awaiting execution.intReturns a snapshot of the calls currently being executed.intvoidsetIdleCallback(Runnable idleCallback) Set a callback to be invoked each time the dispatcher becomes idle (when the number of running calls returns to zero).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.
-
构造器详细资料
-
Dispatcher
-
Dispatcher
public Dispatcher()
-
-
方法详细资料
-
executorService
-
getMaxRequests
public int getMaxRequests() -
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. -
getMaxRequestsPerHost
public int getMaxRequestsPerHost() -
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.WebSocket connections to hosts do not count against this limit.
-
setIdleCallback
Set a callback to be invoked each time the dispatcher becomes idle (when the number of running calls returns to zero).Note: The time at which a call is considered idle is different depending on whether it was run asynchronously or synchronously. Asynchronous calls become idle after the
onResponseoronFailurecallback has returned. Synchronous calls become idle onceexecute()returns. This means that if you are doing synchronous calls the network layer will not truly be idle until every returnedResponsehas been closed. -
cancelAll
public void cancelAll()Cancel all calls currently enqueued or executing. Includes calls executed both synchronously and asynchronously. -
queuedCalls
Returns a snapshot of the calls currently awaiting execution. -
runningCalls
Returns a snapshot of the calls currently being executed. -
queuedCallsCount
public int queuedCallsCount() -
runningCallsCount
public int runningCallsCount()
-