|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.advel.stack.Stack
public class Stack
Support for stack allocation of "value" objects. The only requirements for "value"
objects is that they must have public zero argument constructor and set
method with one argument of the same type (or superclass) which copies data from
given instance.
Example usage:
public static Vector3f average(Vector3f v1, Vector3f v2, Vector3f out) { out.add(v1, v2); out.scale(0.5f); return out; } public static void test() { Vector3f v1 = Stack.alloc(Vector3f.class); v1.set(0f, 1f, 2f); Vector3f v2 = Stack.alloc(v1); v2.x = 10f; Vector3f avg = average(v1, v2, Stack.alloc(Vector3f.class)); }which is transformed into something like the following code. The actual generated code has mangled names for unique type identification and can have other minor differences.
public static void test() { $Stack stack = $Stack.get(); stack.pushVector3f(); try { Vector3f v1 = stack.getVector3f(); v1.set(0f, 1f, 2f); Vector3f v2 = stack.getVector3f(v1); v2.x = 10f; Vector3f avg = average(v1, v2, stack.getVector3f()); } finally { stack.popVector3f(); } }Rules:
cleanCurrentThread
method on thread just before destroying
Method Summary | ||
---|---|---|
static
|
alloc(java.lang.Class<T> cls)
Returns stack allocated object. |
|
static
|
alloc(T obj)
Returns stack allocated object with copied value from given parameter. |
|
static void |
cleanCurrentThread()
Removes all cached stack instances for current thread. |
|
static void |
internalRegisterThreadLocal(java.lang.ThreadLocal local)
Used internally. |
|
static void |
libraryCleanCurrentThread()
Removes all cached stack instances for current thread in current library. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T alloc(java.lang.Class<T> cls)
Requires instrumentation of your classes in order to work.
cls
- class type, must be compile-time constant
public static <T> T alloc(T obj)
Requires instrumentation of your classes in order to work.
obj
- object to copy on stack, the type must be statically known
public static void internalRegisterThreadLocal(java.lang.ThreadLocal local)
public static void cleanCurrentThread()
public static void libraryCleanCurrentThread()
Requires instrumentation of your classes in order to work.
InstrumentationTask.setIsolated(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |