|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.realtime.RealtimeObject
javolution.realtime.StackReference<T>
public final class StackReference<T>
This class encapsulates a reference allocated on the current stack
when executing in PoolContext. The reachability level of a
stack reference is the scope of the PoolContext in which it
has been created.
Stack references are automatically cleared based upon their
reachability level like any java.lang.ref.Reference.
In other words, stack references are automatically cleared when exiting
the PoolContext where they have been factory produced.
Stack references are typically used by functions having more than one
return value to avoid creating new objects on the heap. For example:
See also
// Returns both the position and its status.
public Coordinates getPosition(Reference<Status> status) {
...
}
...
StackReference<Status> status = StackReference.newInstance(); // On the stack.
Coordinates position = getPosition(status);
if (status.get() == ACCURATE) ...ConcurrentContext for examples of
StackReference usage.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javolution.realtime.RealtimeObject |
|---|
RealtimeObject.Factory<T extends RealtimeObject> |
| Nested classes/interfaces inherited from interface javolution.realtime.Realtime |
|---|
Realtime.ObjectSpace |
| Method Summary | ||
|---|---|---|
T |
get()
Returns the value this reference referes to. |
|
static
|
newInstance()
Returns a new stack reference instance allocated on the current stack when executing in PoolContext. |
|
void |
set(T value)
Sets the value this reference referes to. |
|
Text |
toText()
Returns the text representation of the current value of this reference. |
|
| Methods inherited from class javolution.realtime.RealtimeObject |
|---|
export, move, moveHeap, preserve, recycle, toString, unpreserve |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static <T> StackReference<T> newInstance()
PoolContext.
public Text toText()
toText in interface RealtimetoText in class RealtimeObjectText.valueOf(this.get())public T get()
Reference
get in interface Reference<T>null if not set.public void set(T value)
Reference
set in interface Reference<T>value - the reference value.
|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||