[jbpm-commits] JBoss JBPM SVN: r4147 - jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Mar 5 01:21:50 EST 2009
Author: alex.guizar at jboss.com
Date: 2009-03-05 01:21:49 -0500 (Thu, 05 Mar 2009)
New Revision: 4147
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java
Log:
replace Stack in ExecutionContext with List to eliminate the undue synchronization overhead
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java 2009-03-05 06:12:12 UTC (rev 4146)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java 2009-03-05 06:21:49 UTC (rev 4147)
@@ -21,7 +21,8 @@
*/
package org.jbpm.graph.exe;
-import java.util.Stack;
+import java.util.ArrayList;
+import java.util.List;
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
@@ -286,27 +287,29 @@
// thread local execution context
- static ThreadLocal<Stack<ExecutionContext>> threadLocalContextStack = new ThreadLocal<Stack<ExecutionContext>>();
-
- static Stack<ExecutionContext> getContextStack()
+ static final ThreadLocal<List<ExecutionContext>> threadLocalContextStack = new ThreadLocal<List<ExecutionContext>>()
{
- Stack<ExecutionContext> stack = threadLocalContextStack.get();
- if (stack == null)
+ @Override
+ protected List<ExecutionContext> initialValue()
{
- stack = new Stack<ExecutionContext>();
- threadLocalContextStack.set(stack);
+ return new ArrayList<ExecutionContext>();
}
- return stack;
+ };
+
+ static List<ExecutionContext> getContextStack()
+ {
+ return threadLocalContextStack.get();
}
public static void pushCurrentContext(ExecutionContext executionContext)
{
- getContextStack().push(executionContext);
+ getContextStack().add(executionContext);
}
public static void popCurrentContext(ExecutionContext executionContext)
{
- if (getContextStack().pop() != executionContext)
+ List<ExecutionContext> contextStack = getContextStack();
+ if (contextStack.remove(contextStack.size() - 1) != executionContext)
{
throw new JbpmException("current execution context mismatch. make sure that every pushed context gets popped");
}
@@ -315,10 +318,10 @@
public static ExecutionContext currentExecutionContext()
{
ExecutionContext executionContext = null;
- Stack<ExecutionContext> stack = getContextStack();
+ List<ExecutionContext> stack = getContextStack();
if (!stack.isEmpty())
{
- executionContext = stack.peek();
+ executionContext = stack.get(stack.size() - 1);
}
return executionContext;
}
More information about the jbpm-commits
mailing list