geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r573407 - in /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc: AsyncHttpClient.java codec/HttpIoHandler.java
Date Thu, 06 Sep 2007 23:06:27 GMT
Author: jgenender
Date: Thu Sep  6 16:06:27 2007
New Revision: 573407

URL: http://svn.apache.org/viewvc?rev=573407&view=rev
Log:
Use concurrent queue

Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java?rev=573407&r1=573406&r2=573407&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java (original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java Thu
Sep  6 16:06:27 2007
@@ -37,6 +37,7 @@
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.ConcurrentLinkedQueue;
 
 public class AsyncHttpClient {
 
@@ -51,7 +52,7 @@
     private IoSession session;
     private AsyncHttpClientCallback callback;
     private int requestTimeout = DEFAULT_REQUEST_TIMEOUT;
-    private List<HttpRequestMessage> sendQueue = Collections.synchronizedList(new LinkedList<HttpRequestMessage>());
+    private ConcurrentLinkedQueue<HttpRequestMessage> sendQueue = new ConcurrentLinkedQueue<HttpRequestMessage>();
     private ConnectionListener connectionListener = new ConnectionListener();
 
     public AsyncHttpClient(URL url, AsyncHttpClientCallback callback) {
@@ -125,9 +126,11 @@
 
     private synchronized void processSendQueue() {
         if (session != null && session.isConnected()) {
-            while (sendQueue.size() > 0) {
+            while (true) {
                 //Process messages in FIFO
-                HttpRequestMessage message = sendQueue.remove(0);
+                HttpRequestMessage message = sendQueue.poll();
+                if (message == null)
+                    break;
                 session.write(message);
             }
         }

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java?rev=573407&r1=573406&r2=573407&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java
(original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java
Thu Sep  6 16:06:27 2007
@@ -27,10 +27,7 @@
 import java.util.LinkedList;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.*;
 
 public class HttpIoHandler extends IoHandlerAdapter {
 
@@ -38,7 +35,7 @@
     public final static String CONNECTION_CLOSE = "close";
 
     private AsyncHttpClientCallback callback;
-    private List<HttpRequestMessage> sentQueue = Collections.synchronizedList(new LinkedList<HttpRequestMessage>());
+    private ConcurrentLinkedQueue<HttpRequestMessage> sentQueue = new ConcurrentLinkedQueue<HttpRequestMessage>();
     private ScheduledThreadPoolExecutor scheduler = null;
     private int timeoutDelay;
     private AsyncHttpClient.ConnectionListener connectionListener = null;
@@ -64,7 +61,7 @@
         //For each send, we should have a response
         HttpResponseMessage response = (HttpResponseMessage) object;
         //Remove the sent message
-        HttpRequestMessage request = sentQueue.remove(0);
+        HttpRequestMessage request = sentQueue.poll();
         ScheduledFuture handle = request.getTimeoutHandle();
         if (handle != null) {
 



Mime
View raw message