Class ThreadSafeEvaluator
- java.lang.Object
-
- com.singularsys.jep.standard.FastEvaluator
-
- com.singularsys.jep.misc.threadsafeeval.ThreadSafeEvaluator
-
- All Implemented Interfaces:
Evaluator
,JepComponent
,ParserVisitor
,java.io.Serializable
public class ThreadSafeEvaluator extends FastEvaluator
An evaluator which can safely evaluate an expression in multiple threads. It works by finding the name of a variable from a Node and then using that name to find the variable from the variable table. In essence it adds one hash table lookup for each variable reference.- Since:
- Jep 3.5
- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Jep
jep
protected VariableTable
vt
-
Fields inherited from class com.singularsys.jep.standard.FastEvaluator
trapInfinity, trapNaN, trapNullValues, trapUnsetValues
-
-
Constructor Summary
Constructors Constructor Description ThreadSafeEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JepComponent
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.Variable
getVariable(java.lang.String name)
void
init(Jep jep1)
Initialize the component.java.lang.Object
visitVar(Node node)
-
Methods inherited from class com.singularsys.jep.standard.FastEvaluator
eval, evaluate, isTrapInfinity, isTrapNaN, isTrapNullValues, isTrapUnsetValues, nodeAccept, setTrapInfinity, setTrapNaN, setTrapNullValues, setTrapUnsetValues, visit, visit, visit, visit, visitConstant, visitFun
-
-
-
-
Field Detail
-
jep
protected Jep jep
-
vt
protected VariableTable vt
-
-
Method Detail
-
init
public void init(Jep jep1)
Description copied from interface:JepComponent
Initialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.- Specified by:
init
in interfaceJepComponent
- Overrides:
init
in classFastEvaluator
- Parameters:
jep1
- the current Jep instance
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Overrides:
getLightWeightInstance
in classFastEvaluator
- Returns:
- an new FastEvaluator
-
getVariable
public Variable getVariable(java.lang.String name)
-
visitVar
public java.lang.Object visitVar(Node node) throws EvaluationException
- Overrides:
visitVar
in classFastEvaluator
- Throws:
EvaluationException
-
-