public class Stack
extends java.lang.Object
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
Modifier and Type | Method and Description |
---|---|
static <T> T |
alloc(java.lang.Class<T> cls)
Returns stack allocated object.
|
static <T> T |
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.
|
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 constantpublic 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 knownpublic static void internalRegisterThreadLocal(java.lang.ThreadLocal local)
public static void cleanCurrentThread()
public static void libraryCleanCurrentThread()
Requires instrumentation of your classes in order to work.