Class RealtimeObject
- java.lang.Object
-
- javolution37.javolution.realtime.RealtimeObject
-
- All Implemented Interfaces:
- Realtime
- Direct Known Subclasses:
- CharacterData, FastCollection, FastMap, StackReference, Text, TextBuilder
public abstract class RealtimeObject extends java.lang.Object implements Realtime
This class provides a default implementation of the
Realtimeinterface.Instances of this class should be created using the inner
Factoryclass. For example:public class Foo extends RealtimeObject { static final Factory<Foo> FACTORY = new Factory<Foo>() { protected Foo create() { return new Foo(); } }; protected Foo() {} // Default constructor for sub-classes. public static Foo newInstance() { // Static factory method. return FACTORY.object(); } // Optional. public boolean move(ObjectSpace os) { ... } }Instances of this class can be immutable. Instances allocated in a
pool contextmust beexported(e.g. return value) orpreserved(e.g. static instance) if referenced after exiting the pool context.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classRealtimeObject.Factory<T extends RealtimeObject>This abstract class represents the factory responsible for the creation ofRealtimeObjectinstances.-
Nested classes/interfaces inherited from interface javolution37.javolution.realtime.Realtime
Realtime.ObjectSpace
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description <T> Texport()Exports this object and its local real-time associations out of the current pool context (equivalent to).move(ObjectSpace.OUTER)booleanmove(Realtime.ObjectSpace os)Moves this real-time object to the specified object space.<T> TmoveHeap()Moves this object and its real-time associations to the heap (equivalent to).move(ObjectSpace.HEAP)<T> Tpreserve()Prevents this object and its real-time associations to be recycled (equivalent to).move(ObjectSpace.HOLD)java.lang.StringtoString()Returns theStringrepresentation of this object.TexttoText()Returns the default textual representation of this realtime object.<T> Tunpreserve()Allows this object and its real-time associations to be recycled if not preserved any more (equivalent to).move(ObjectSpace.STACK)
-
-
-
Method Detail
-
toString
public final java.lang.String toString()
Returns theStringrepresentation of this object. This method is final to ensure consistency withtoText()(which is the method to override).- Overrides:
toStringin classjava.lang.Object- Returns:
toText().stringValue()
-
toText
public Text toText()
Returns the default textual representation of this realtime object.
-
export
public final <T> T export()
Exports this object and its local real-time associations out of the current pool context (equivalent to). This method affects only local objects allocated on the stack and has no effect on heap objects or objects allocated outside of the current pool context.move(ObjectSpace.OUTER)Note: To avoid pool depletion when exporting to outer pool, the object is actually exchanged with an outer pool object.
- Returns:
this
-
moveHeap
public final <T> T moveHeap()
Moves this object and its real-time associations to the heap (equivalent to).move(ObjectSpace.HEAP)- Returns:
this
-
preserve
public final <T> T preserve()
Prevents this object and its real-time associations to be recycled (equivalent to). This method increments this object preserved counter.move(ObjectSpace.HOLD)- Returns:
this- See Also:
unpreserve()
-
unpreserve
public final <T> T unpreserve()
Allows this object and its real-time associations to be recycled if not preserved any more (equivalent to). This method decrements this object preserved counter.move(ObjectSpace.STACK)- Returns:
this- See Also:
preserve()
-
move
public boolean move(Realtime.ObjectSpace os)
Description copied from interface:RealtimeMoves this real-time object to the specified object space.
-
-
DMelt 3.0 © DataMelt by jWork.ORG