Author: remm
Date: Fri Feb 27 16:51:20 2015
New Revision: 1662748

URL: http://svn.apache.org/r1662748
Log:
Drop use of a complex recycling structure which saved allocation of a very 
simple object at the likely cost of significant syncing. Will revert if it is 
believed it actually had some sort of beneficial impact (given my experience 
with the NIO2 connector which doesn't use the object caches by default, I would 
say no).

Modified:
    
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java

Modified: 
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java?rev=1662748&r1=1662747&r2=1662748&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
 Fri Feb 27 16:51:20 2015
@@ -20,8 +20,6 @@ import java.io.EOFException;
 import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ExecutorService;
 
 import javax.websocket.SendHandler;
@@ -45,9 +43,6 @@ public class WsRemoteEndpointImplServer
     private static final Log log =
             LogFactory.getLog(WsHttpUpgradeHandler.class);
 
-    private static final Queue<OnResultRunnable> onResultRunnables =
-            new ConcurrentLinkedQueue<>();
-
     private final SocketWrapperBase<?> socketWrapper;
     private final WsWriteTimeout wsWriteTimeout;
     private final ExecutorService executorService;
@@ -234,11 +229,7 @@ public class WsRemoteEndpointImplServer
         buffers = null;
         if (sh != null) {
             if (useDispatch) {
-                OnResultRunnable r = onResultRunnables.poll();
-                if (r == null) {
-                    r = new OnResultRunnable(onResultRunnables);
-                }
-                r.init(sh, t);
+                OnResultRunnable r = new OnResultRunnable(sh, t);
                 if (executorService == null || executorService.isShutdown()) {
                     // Can't use the executor so call the runnable directly.
                     // This may not be strictly specification compliant in all
@@ -264,16 +255,10 @@ public class WsRemoteEndpointImplServer
 
     private static class OnResultRunnable implements Runnable {
 
-        private final Queue<OnResultRunnable> queue;
-
-        private volatile SendHandler sh;
-        private volatile Throwable t;
-
-        private OnResultRunnable(Queue<OnResultRunnable> queue) {
-            this.queue = queue;
-        }
+        private final SendHandler sh;
+        private final Throwable t;
 
-        private void init(SendHandler sh, Throwable t) {
+        private OnResultRunnable(SendHandler sh, Throwable t) {
             this.sh = sh;
             this.t = t;
         }
@@ -285,12 +270,6 @@ public class WsRemoteEndpointImplServer
             } else {
                 sh.onResult(new SendResult(t));
             }
-            t = null;
-            sh = null;
-            // Return the Runnable to the queue when it has been finished with
-            // Note if this method takes an age to finish there shouldn't be 
any
-            // thread safety issues as the fields are cleared above.
-            queue.add(this);
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to