-
public final class ConnectionPoolManages reuse of HTTP and HTTP/2 connections for reduced network latency. HTTP requests that share the same Address may share a Connection. This class implements the policy of which connections to keep open for future use.
-
-
Constructor Summary
Constructors Constructor Description ConnectionPool()Create a new connection pool with tuning parameters appropriate for a single-user application.The tuning parameters in this pool are subject to change in future OkHttp releases. ConnectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit)
-
Method Summary
Modifier and Type Method Description synchronized intidleConnectionCount()Returns the number of idle connections in the pool. synchronized intconnectionCount()Returns total number of connections in the pool. voidevictAll()Close and remove all idle connections in the pool. -
-
Constructor Detail
-
ConnectionPool
ConnectionPool()
Create a new connection pool with tuning parameters appropriate for a single-user application.The tuning parameters in this pool are subject to change in future OkHttp releases.
-
ConnectionPool
ConnectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit)
-
-
Method Detail
-
idleConnectionCount
synchronized int idleConnectionCount()
Returns the number of idle connections in the pool.
-
connectionCount
synchronized int connectionCount()
Returns total number of connections in the pool. Note that prior to OkHttp 2.7 this includedonly idle connections and HTTP/2 connections. Since OkHttp 2.7 this includes all connections,both active and inactive. Use idleConnectionCount to count connections not currentlyin use.
-
evictAll
void evictAll()
Close and remove all idle connections in the pool.
-
-
-
-