geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r573709 - /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java
Date Fri, 07 Sep 2007 21:08:52 GMT
Author: jgenender
Date: Fri Sep  7 14:08:51 2007
New Revision: 573709

URL: http://svn.apache.org/viewvc?rev=573709&view=rev
Log:
Just a single scheduler per object

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

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=573709&r1=573708&r2=573709&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
Fri Sep  7 14:08:51 2007
@@ -36,7 +36,7 @@
 
     private AsyncHttpClientCallback callback;
     private ConcurrentLinkedQueue<HttpRequestMessage> sentQueue = new ConcurrentLinkedQueue<HttpRequestMessage>();
-    private ScheduledThreadPoolExecutor scheduler = null;
+    private ScheduledExecutorService scheduler = null;
     private int timeoutDelay;
     private AsyncHttpClient.ConnectionListener connectionListener = null;
 
@@ -48,11 +48,7 @@
 
     public void sessionOpened(IoSession ioSession) throws Exception {
         if (timeoutDelay > 0) {
-            scheduler = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(DEFAULT_THREAD_POOL_SIZE);
-
-            //Install the schedule purger to purge any cancelled tasks
-            //to prevent memory leaks
-            scheduler.scheduleWithFixedDelay(new SchedulePurger(), 5000, 5000, TimeUnit.MILLISECONDS);
+            scheduler = Executors.newSingleThreadScheduledExecutor();
         }
         connectionListener.onConnected(ioSession);
     }
@@ -94,7 +90,6 @@
         ioSession.removeAttribute(HttpResponseDecoder.CURRENT_RESPONSE);
         if (timeoutDelay > 0) {
             sentQueue.clear();
-            scheduler.purge();
             scheduler.shutdownNow();
             scheduler = null;
         }
@@ -108,17 +103,6 @@
             scheduler.schedule(task, timeoutDelay, TimeUnit.MILLISECONDS);
             sentQueue.add(msg);
         }
-    }
-
-    /**
-     * Task to remove cancelled tasks from the scheduler
-     */
-    class SchedulePurger implements Runnable {
-
-        public void run() {
-            scheduler.purge();
-        }
-
     }
 
     class TimeoutTask implements Runnable {



Mime
View raw message