hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r756799 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn: IdleConnectionHandler.java tsccm/AbstractConnPool.java tsccm/RouteSpecificPool.java
Date Fri, 20 Mar 2009 23:05:07 GMT
Author: sebb
Date: Fri Mar 20 23:05:07 2009
New Revision: 756799

URL: http://svn.apache.org/viewvc?rev=756799&view=rev
Log:
Concurrency documentation

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java?rev=756799&r1=756798&r2=756799&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
Fri Mar 20 23:05:07 2009
@@ -35,11 +35,13 @@
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import net.jcip.annotations.NotThreadSafe;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.HttpConnection;
 
-
+// Currently only used by AbstractConnPool
 /**
  * A helper class for connection managers to track idle connections.
  * 
@@ -49,6 +51,7 @@
  * 
  * @since 4.0
  */
+@NotThreadSafe
 public class IdleConnectionHandler {
 
     private final Log log = LogFactory.getLog(getClass());

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java?rev=756799&r1=756798&r2=756799&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
Fri Mar 20 23:05:07 2009
@@ -60,7 +60,7 @@
  *
  * @since 4.0
  */
-@NotThreadSafe // unsynch access to queues etc
+@NotThreadSafe // unsynch access to refQueue, refWorker
 public abstract class AbstractConnPool implements RefQueueHandler {
 
     private final Log log = LogFactory.getLog(getClass());
@@ -77,10 +77,13 @@
      * {@link BasicPoolEntryRef BasicPoolEntryRef},
      * and point to the pool entry for the issued connection.
      * GCed connections are detected by the missing pool entries.
+     * Must hold poolLock when accessing.
      */
+    @GuardedBy("poolLock")
     protected Set<BasicPoolEntryRef> issuedConnections;
 
-    /** The handler for idle connections. */
+    /** The handler for idle connections. Must hold poolLock when accessing. */
+    @GuardedBy("poolLock")
     protected IdleConnectionHandler idleConnHandler;
 
     /** The current total number of connections. */
@@ -92,9 +95,11 @@
      * The same queue is used to track loss of the connection manager,
      * so we cannot specialize the type.
      */
+    // TODO - this needs to be synchronized, e.g. on Pool Lock
     protected ReferenceQueue<Object> refQueue;
 
     /** A worker (thread) to track loss of pool entries to GC. */
+    // TODO - this needs to be synchronized, e.g. on Pool Lock
     private RefQueueWorker refWorker;
 
 
@@ -127,7 +132,7 @@
     public void enableConnectionGC()
         throws IllegalStateException {
 
-        if (refQueue != null) {
+        if (refQueue != null) { // TODO - this access is not guaranteed protected by the
pool lock
             throw new IllegalStateException("Connection GC already enabled.");
         }
         poolLock.lock();

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java?rev=756799&r1=756798&r2=756799&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
Fri Mar 20 23:05:07 2009
@@ -35,6 +35,8 @@
 import java.util.Queue;
 import java.util.LinkedList;
 
+import net.jcip.annotations.NotThreadSafe;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.conn.OperatedClientConnection;
@@ -49,12 +51,13 @@
  *
  * @since 4.0
  */
+@NotThreadSafe // e.g. numEntries, freeEntries, 
 public class RouteSpecificPool {
 
     private final Log log = LogFactory.getLog(getClass());
     
     /** The route this pool is for. */
-    protected final HttpRoute route;
+    protected final HttpRoute route; //Immutable
 
     /** the maximum number of entries allowed for this pool */
     protected final int maxEntries;



Mime
View raw message