|
J avolution v5.5 (J2SE 1.6+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ValueType
This interface identifies objects which can be manipulated by value; a JVM implementation may allocate instances of this class on the stack and pass references by copy.
Realtime
instances can be "explicitly" allocated on the
"stack" by executing within a StackContext
and creating new instances with an ObjectFactory
.
It is the responsibility of the users to ensure
that "stack" objects are copied out
when
referenced outside of the stack context. For example:
public final class Complex implements Realtime, ValueType { ... }
...
public Complex sumOf(Complex[] values) {
StackContext.enter(); // Starts stack allocation.
try {
Complex sum = Complex.ZERO;
for (Complex c : values) {
sum = sum.plus(c);
}
return StackContext.outerCopy(sum); // Copies outside the stack.
} finally {
StackContext.exit(); // Resets stacks.
}
}
Note: "Stack" allocation is not the only optimization that a VM
can do on ValueType
. The VM might decide not to perform any
allocation at all and store values directly in registers.
Method Summary | |
---|---|
java.lang.Object |
copy()
Returns a deep copy of this object allocated in the memory area (RTSJ) and/or context (Javolution)
of the calling thread (the one making the copy). |
Method Detail |
---|
java.lang.Object copy()
context
(Javolution)
of the calling thread (the one making the copy).
|
J avolution v5.5 (J2SE 1.6+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |