Documentation of 'javolution37.javolution.realtime.RealtimeObject' Java class
RealtimeObject
javolution37.javolution.realtime

Class 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 Realtime interface.

    Instances of this class should be created using the inner Factory class. 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 context must be exported (e.g. return value) or preserved (e.g. static instance) if referenced after exiting the pool context.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      <T> T export()
      Exports this object and its local real-time associations out of the current pool context (equivalent to move (ObjectSpace.OUTER)).
      boolean move(Realtime.ObjectSpace os)
      Moves this real-time object to the specified object space.
      <T> T moveHeap()
      Moves this object and its real-time associations to the heap (equivalent to move(ObjectSpace.HEAP)).
      <T> T preserve()
      Prevents this object and its real-time associations to be recycled (equivalent to move(ObjectSpace.HOLD)).
      java.lang.String toString()
      Returns the String representation of this object.
      Text toText()
      Returns the default textual representation of this realtime object.
      <T> T unpreserve()
      Allows this object and its real-time associations to be recycled if not preserved any more (equivalent to move(ObjectSpace.STACK)).
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • toString

        public final java.lang.String toString()
        Returns the String representation of this object. This method is final to ensure consistency with toText() (which is the method to override).
        Overrides:
        toString in class java.lang.Object
        Returns:
        toText().stringValue()
      • toText

        public Text toText()
        Returns the default textual representation of this realtime object.
        Specified by:
        toText in interface Realtime
        Returns:
        the textual representation of this object.
      • export

        public final <T> T export()
        Exports this object and its local real-time associations out of the current pool context (equivalent to move (ObjectSpace.OUTER)). 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.

        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 move(ObjectSpace.HOLD)). This method increments this object preserved counter.
        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 move(ObjectSpace.STACK)). This method decrements this object preserved counter.
        Returns:
        this
        See Also:
        preserve()
      • move

        public boolean move(Realtime.ObjectSpace os)
        Description copied from interface: Realtime
        Moves this real-time object to the specified object space.
        Specified by:
        move in interface Realtime
        Parameters:
        os - the object space to move this real-time object to.
        Returns:
        true if the move has to be propagated to external real-time references; false otherwise.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.