JADE v6.1

com.dautelle.realtime
Class RealtimeObject

java.lang.Object
  extended bycom.dautelle.realtime.RealtimeObject
All Implemented Interfaces:
Realtime, java.io.Serializable
Direct Known Subclasses:
FastList, FastMap, FastSet, FastString, Function, LUDecomposition, Matrix, Polynomial.Term

public abstract class RealtimeObject
extends java.lang.Object
implements Realtime, java.io.Serializable

This class provides a default implementation of the Realtime interface.

Instances of this class should be created using a RealtimeObject.Factory. For example:

     public class Foo extends RealtimeObject {
         static final Factory FACTORY = new Factory() {
             public Object create() {
                 return new Foo();
             }
         };
         protected Foo() {} // Default constructor for sub-classes. 
         public static Foo newInstance() { // Static factory method.
             return (Foo) FACTORY.object();
         }
         public Object export() { // Optional, only if new real-time members.
             ... // Exports new real-time variable members.
             return super.export();
         }
         public Object toHeap() { // Optional, only if new real-time members.
             ... // Moves to heap new real-time variable members.
             return super.toHeap();
         }
     }

Instances of this class can be immutable. Instances allocated in a pool context must be exported if referenced after exiting the pool context.

Version:
6.0, May 18, 2004
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Nested Class Summary
protected static class RealtimeObject.Factory
          This abstract class represents the factory responsible for the creation of RealtimeObject instances.
 
Constructor Summary
protected RealtimeObject()
          Default constructor.
 
Method Summary
protected  java.lang.Object clone()
          Overrides the clone method to ensure that the copy references the heap pool.
 java.lang.Object export()
          Exports this object out of the current pool context.
 boolean isLocalObject()
          Indicates if this object is an object local to the current pool context.
 boolean isPoolObject()
          Indicates if this object belongs to a pool (stack allocated object).
protected  void recycle()
          Recycles this object.
 java.lang.Object toHeap()
          Moves this object to the heap.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RealtimeObject

protected RealtimeObject()
Default constructor.

Method Detail

isLocalObject

public final boolean isLocalObject()
Indicates if this object is an object local to the current pool context. Operations on local objects do not require synchronization as these objects are accessible to the current thread only.

Note: Due to the "export" rule, non-local objects cannot refer to local object.

Returns:
true if this object belongs to the current pool context; false otherwise.

isPoolObject

public final boolean isPoolObject()
Indicates if this object belongs to a pool (stack allocated object).

Note: Due to the "export" rule, heap objects cannot refer to pool object.

Returns:
true if this object belongs to a pool; false if this object belongs to the heap.

recycle

protected void recycle()
Recycles this object. This method should only be called when it can be asserted that this object is not going to be referenced anymore. This method affects only local objects and has no effect on heap objects or objects allocated outside of the current pool context. Recycling is limited to this object and its internal and has no effect on any shared member.


export

public java.lang.Object export()
Description copied from interface: Realtime
Exports this object out of the current pool context. Realtime members are exported as well (recursion). This method affects only objects belonging to the current pool context. To avoid pool depletion, a "free" object from the outer pool is moved to replace the object being exported.

Specified by:
export in interface Realtime
Returns:
this

toHeap

public java.lang.Object toHeap()
Description copied from interface: Realtime
Moves this object to the heap. Realtime members are moved to the heap as well (recursion). This method affects only objects belonging to a pool context (current or not).

Specified by:
toHeap in interface Realtime
Returns:
this

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides the clone method to ensure that the copy references the heap pool.

Returns:
this object's clone allocated on the heap.
Throws:
java.lang.CloneNotSupportedException

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.