You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2007/12/14 11:20:42 UTC

svn commit: r604148 - in /jakarta/httpcomponents/httpcore/trunk: RELEASE_NOTES.txt module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java

Author: olegk
Date: Fri Dec 14 02:20:42 2007
New Revision: 604148

URL: http://svn.apache.org/viewvc?rev=604148&view=rev
Log:
No need to use a queue for suspended endpoints. Simple set can do; Allow suspended endpoint impls to be GC-ed; Updated release notes

Modified:
    jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java

Modified: jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=604148&r1=604147&r2=604148&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Fri Dec 14 02:20:42 2007
@@ -1,5 +1,9 @@
 Changes since 4.0 Alpha 6
 
+* [HTTPCORE-127] Improved API for lifecycle management of listening I/O
+  reactors. One can now suspend and resume listener endpoints.
+  Contributed by Asankha C. Perera <asankha at wso2.com>
+
 * [HTTPCORE-112] DefaultConnectionReuseStrategy interprets token sequences
   Contributed by Roland Weber <rolandw at apache.org>
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java?rev=604148&r1=604147&r2=604148&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java Fri Dec 14 02:20:42 2007
@@ -38,6 +38,7 @@
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Queue;
@@ -55,7 +56,7 @@
         implements ListeningIOReactor {
 
     private final Queue<ListenerEndpointImpl> requestQueue;
-    private final Queue<ListenerEndpointImpl> pausedQueue;
+    private final Set<SocketAddress> pausedEndpoints;
     
     public DefaultListeningIOReactor(
             int workerCount, 
@@ -63,7 +64,7 @@
             final HttpParams params) throws IOReactorException {
         super(workerCount, threadFactory, params);
         this.requestQueue = new ConcurrentLinkedQueue<ListenerEndpointImpl>();
-        this.pausedQueue = new ConcurrentLinkedQueue<ListenerEndpointImpl>();
+        this.pausedEndpoints = new HashSet<SocketAddress>();
     }
 
     public DefaultListeningIOReactor(
@@ -191,7 +192,7 @@
                     ListenerEndpointImpl endpoint = (ListenerEndpointImpl) key.attachment();
                     if (endpoint != null) {
                         endpoint.close();
-                        this.pausedQueue.add(endpoint);
+                        this.pausedEndpoints.add(endpoint.getAddress());
                     }
                 }
             }
@@ -199,12 +200,12 @@
     }
 
     public void resume() throws IOException {
-        ListenerEndpointImpl endpoint;
-        while ((endpoint = this.pausedQueue.poll()) != null) {
-            ListenerEndpointImpl request = new ListenerEndpointImpl(endpoint.getAddress());
+        for (SocketAddress socketAddress: this.pausedEndpoints) {
+            ListenerEndpointImpl request = new ListenerEndpointImpl(socketAddress);
             this.requestQueue.add(request);
         }
-        this.pausedQueue.clear();
+        this.pausedEndpoints.clear();
         this.selector.wakeup();
     }
+    
 }