Repository: tapestry-5
Updated Branches:
  refs/heads/master 888b73278 -> a6f8d6f83


Replace synchronization by a cuncurrent queue. This should speed up the initial 
pool population because executors can be created in parallel


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/a6f8d6f8
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/a6f8d6f8
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/a6f8d6f8

Branch: refs/heads/master
Commit: a6f8d6f830b9d2da93eadfa36c89df75dbbe480c
Parents: 888b732
Author: Jochen Kemnade <[email protected]>
Authored: Fri Nov 27 14:48:27 2015 +0100
Committer: Jochen Kemnade <[email protected]>
Committed: Fri Nov 27 14:48:27 2015 +0100

----------------------------------------------------------------------
 .../internal/webresources/RhinoExecutorPool.java   | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a6f8d6f8/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/RhinoExecutorPool.java
----------------------------------------------------------------------
diff --git 
a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/RhinoExecutorPool.java
 
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/RhinoExecutorPool.java
index ae25313..27fadbf 100644
--- 
a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/RhinoExecutorPool.java
+++ 
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/RhinoExecutorPool.java
@@ -17,10 +17,8 @@ package org.apache.tapestry5.internal.webresources;
 import org.apache.tapestry5.ioc.Invokable;
 import org.apache.tapestry5.ioc.OperationTracker;
 import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.util.ExceptionUtils;
-import org.apache.tapestry5.ioc.util.Stack;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.ContextFactory;
 import org.mozilla.javascript.NativeFunction;
@@ -31,6 +29,8 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
 
 /**
  * Manages a pool of initialized {@link RhinoExecutor} instances.  The 
instances are initialized for a particular
@@ -41,7 +41,7 @@ public class RhinoExecutorPool
 
     private final List<Resource> scripts;
 
-    private final Stack<RhinoExecutor> executors = 
CollectionFactory.newStack();
+    private final Queue<RhinoExecutor> executors = new 
ConcurrentLinkedQueue<RhinoExecutor>();
 
     private final ContextFactory contextFactory = new ContextFactory();
 
@@ -57,20 +57,21 @@ public class RhinoExecutorPool
      *
      * @return executor
      */
-    public synchronized RhinoExecutor get()
+    public RhinoExecutor get()
     {
 
-        if (executors.isEmpty())
+        RhinoExecutor executor = executors.poll();
+        if (executor != null)
         {
-            return createExecutor();
+            return executor;
         }
 
-        return executors.pop();
+        return createExecutor();
     }
 
     private synchronized void put(RhinoExecutor executor)
     {
-        executors.push(executor);
+        executors.add(executor);
     }
 
     private RhinoExecutor createExecutor()

Reply via email to