Class StackReference<T>
- java.lang.Object
-
- javolution37.javolution.realtime.RealtimeObject
-
- javolution37.javolution.realtime.StackReference<T>
-
public final class StackReference<T> extends RealtimeObject implements Reference<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 thePoolContextin which it has beencreated.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 thePoolContextwhere 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) ...ConcurrentContextfor examples ofStackReferenceusage.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javolution37.javolution.realtime.RealtimeObject
RealtimeObject.Factory<T extends RealtimeObject>
-
Nested classes/interfaces inherited from interface javolution37.javolution.realtime.Realtime
Realtime.ObjectSpace
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Tget()Returns the value this reference referes to.static <T> StackReference<T>newInstance()Returns a new stack reference instance allocated on the current stack when executing inPoolContext.voidset(T value)Sets the value this reference referes to.TexttoText()Returns the text representation of the current value of this reference.-
Methods inherited from class javolution37.javolution.realtime.RealtimeObject
export, move, moveHeap, preserve, toString, unpreserve
-
-
-
-
Method Detail
-
newInstance
public static <T> StackReference<T> newInstance()
Returns a new stack reference instance allocated on the current stack when executing inPoolContext.- Returns:
- a local reference object.
-
toText
public Text toText()
Returns the text representation of the current value of this reference.- Specified by:
toTextin interfaceRealtime- Overrides:
toTextin classRealtimeObject- Returns:
Text.valueOf(this.get())
-
get
public T get()
Description copied from interface:ReferenceReturns the value this reference referes to.
-
-
DMelt 3.0 © DataMelt by jWork.ORG