Home | History | Annotate | Download | only in okhttp

Lines Matching defs:connection

38  * {@link Connection}. This class implements the policy of which connections to
49 * connection alive in the pool before closing it. Default is 5 minutes.
81 * thread running per connection pool. We use a thread pool executor because it can shrink to
134 for (RealConnection connection : connections) {
135 if (connection.allocations.isEmpty()) total++;
159 for (RealConnection connection : connections) {
160 if (connection.isMultiplexed()) total++;
170 /** Returns a recycled connection to {@code address}, or null if no such connection exists. */
173 for (RealConnection connection : connections) {
175 // connection.allocationLimit() may also lock the FramedConnection.
176 if (connection.allocations.size() < connection.allocationLimit()
177 && address.equals(connection.getRoute().address)
178 && !connection.noNewStreams) {
179 streamAllocation.acquire(connection);
180 return connection;
186 void put(RealConnection connection) {
191 connections.add(connection);
195 * Notify this pool that {@code connection} has become idle. Returns true if the connection
198 boolean connectionBecameIdle(RealConnection connection) {
200 if (connection.noNewStreams || maxIdleConnections == 0) {
201 connections.remove(connection);
204 notifyAll(); // Awake the cleanup thread: we may have exceeded the idle connection limit.
214 RealConnection connection = i.next();
215 if (connection.allocations.isEmpty()) {
216 connection.noNewStreams = true;
217 evictedConnections.add(connection);
223 for (RealConnection connection : evictedConnections) {
224 Util.closeQuietly(connection.getSocket());
229 * Performs maintenance on this pool, evicting the connection that has been idle the longest if
241 // Find either a connection to evict, or the time that the next eviction is due.
244 RealConnection connection = i.next();
246 // If the connection is in use, keep searching.
247 if (pruneAndGetAllocationCount(connection, now) > 0) {
254 // If the connection is ready to be evicted, we're done.
255 long idleDurationNs = now - connection.idleAtNanos;
258 longestIdleConnection = connection;
264 // We've found a connection to evict. Remove it from the list, then close it below (outside
269 // A connection will be ready to evict soon.
290 * {@code connection}. Allocations are leaked if the connection is tracking them but the
294 private int pruneAndGetAllocationCount(RealConnection connection, long now) {
295 List<Reference<StreamAllocation>> references = connection.allocations;
309 // Internal.logger.warning("A connection to " + connection.getRoute().getAddress().url()
312 connection.noNewStreams = true;
314 // If this was the last allocation, the connection is eligible for immediate eviction.
316 connection.idleAtNanos = now - keepAliveDurationNs;