hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1147280 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
Date Fri, 15 Jul 2011 18:59:51 GMT
Author: jonm
Date: Fri Jul 15 18:59:51 2011
New Revision: 1147280

URL: http://svn.apache.org/viewvc?rev=1147280&view=rev
Log:
HTTPCLIENT-1108: reuse of persistent connections now uses a stack (LIFO)
instead of a queue (FIFO), so that unneeded connections will eventually
become idle and reclaimable by closeIdleConnections().

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java?rev=1147280&r1=1147279&r2=1147280&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
Fri Jul 15 18:59:51 2011
@@ -34,6 +34,7 @@ import java.util.Queue;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.Set;
+import java.util.Stack;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.TimeUnit;
@@ -82,7 +83,7 @@ public class ConnPoolByRoute extends Abs
     protected final Set<BasicPoolEntry> leasedConnections;
 
     /** The list of free connections */
-    protected final Queue<BasicPoolEntry> freeConnections;
+    protected final Stack<BasicPoolEntry> freeConnections;
 
     /** The list of WaitingThreads waiting for a connection */
     protected final Queue<WaitingThread> waitingThreads;
@@ -162,8 +163,8 @@ public class ConnPoolByRoute extends Abs
      *
      * @return  a queue
      */
-    protected Queue<BasicPoolEntry> createFreeConnQueue() {
-        return new LinkedList<BasicPoolEntry>();
+    protected Stack<BasicPoolEntry> createFreeConnQueue() {
+        return new Stack<BasicPoolEntry>();
     }
 
     /**
@@ -462,7 +463,7 @@ public class ConnPoolByRoute extends Abs
                 }
                 rospl.freeEntry(entry);
                 entry.updateExpiry(validDuration, timeUnit);
-                freeConnections.add(entry);
+                freeConnections.push(entry);
             } else {
                 rospl.dropEntry();
                 numConnections--;
@@ -611,7 +612,7 @@ public class ConnPoolByRoute extends Abs
         poolLock.lock();
         try {
 
-            BasicPoolEntry entry = freeConnections.remove();
+            BasicPoolEntry entry = freeConnections.pop();
 
             if (entry != null) {
                 deleteEntry(entry);



Mime
View raw message