vmm3d.functions
Class EvalStack
- java.lang.Object
-
- vmm3d.functions.EvalStack
-
public final class EvalStack extends java.lang.ObjectAn object of type EvalStack is used in the evaluation of an expression or function (as defined, for example, in the classesExpression,Function, andComplexFunction). Thevalue()methods in such expressions and fuctions can, optionally, take a parameter of type EvalStack. In fact, the only thing that you can do with an EvalStack, outside of the package vmm.functions, is construct it and pass it as a parameter to one of thesevalue()methods; the only reason to do this is to evaluate functions and expressions in a thread-safe way.
-
-
Constructor Summary
Constructors Constructor and Description EvalStack()Create an EvalStack with an initial size of 30.EvalStack(int initialSize)Create an EvalStack with a specified initial size.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static EvalStackperThread()Returns an EvalStack that is unique to the current thread.static EvalStackperThread(java.lang.Thread thread)The first time this method is called by a given thread, it creates and returns a new EvalStack; subsequent calls with return the same EvalStack rather than create a new one.static voidperThreadRelease(java.lang.Thread thread)Discard the EvalStack, if any, that has been created for the specified thread byperThread()orperThread(Thread).
-
-
-
Constructor Detail
-
EvalStack
public EvalStack()
Create an EvalStack with an initial size of 30.
-
EvalStack
public EvalStack(int initialSize)
Create an EvalStack with a specified initial size. The size will grow, if necessary, so it is generally sufficient to use the default constructor.- Parameters:
initialSize- the initial size of the stack. If a size less than 1 is specified, then the initial size will be 1.
-
-
Method Detail
-
perThread
public static final EvalStack perThread()
Returns an EvalStack that is unique to the current thread. This method simply callsperThread(Thread), withThread.currentThread()as its parameter.
-
perThread
public static final EvalStack perThread(java.lang.Thread thread)
The first time this method is called by a given thread, it creates and returns a new EvalStack; subsequent calls with return the same EvalStack rather than create a new one. This meant to support thread-safe evalution of functions; this capability is used in evaluation methods such asExpression.value(),Function.value(double[])andComplexFunction.value(Complex[]). The methodperThreadRelease(Thread)can be called to discard the EvalStack that has been created for a given thread.- Parameters:
thread- the Thread whose associated EvalStack is to be returned. If thread is null, the return value is also null.
-
perThreadRelease
public static void perThreadRelease(java.lang.Thread thread)
Discard the EvalStack, if any, that has been created for the specified thread byperThread()orperThread(Thread).- Parameters:
thread- The thread whose EvalStack is to be discarded. If the value is null or if there is not EvalStack for the specified stack, nothing is done; this is not an error.
-
-
DMelt 3.0 © DataMelt by jWork.ORG