javax.realtime
Class LTMemory

java.lang.Object
  |
  +--javax.realtime.MemoryArea
        |
        +--javax.realtime.ScopedMemory
              |
              +--javax.realtime.LTMemory

public class LTMemory
extends ScopedMemory

LTMemory represents a memory area, allocated per RealtimeThread, or for a group of real-time threads, guaranteed by the system to have linear time allocation. The memory area described by a LTMemory instance does not exist in the Java heap, and is not subject to garbage collection. Thus, it is safe to use a LTMemory object as the memory area associated with a NoHeapRealtimeThread, or to enter the memory area using the enter() method within a NoHeapRealtimeThread. An LTMemory area has an initial size. Enough memory must be committed by the completion of the constructor to satisfy this initial requirement. (Committed means that this memory must always be available for allocation). The initial memory allocation must behave, with respect to successful allocation, as if it were contiguous; i.e., a correct implementation must guarantee that any sequence of object allocations that could ever without exceeding a specified initial memory size will always succeed without exceeding that initial memory size and succeed for any instance of LTMemory with that initial memory size. (Note: It is important to understand that the above statement does not require that if the initial memory size is N and (sizeof(object1) + sizeof(object2) + ... + sizeof(objectn) = N) the allocations of objects 1 through n will necessarily succeed.) Execution time of an allocator aloocating from this initial area must be linear in the size of the allocated object. Execution time of an allocator allocating from memory between initial and maximum is allowed to vary. Furthermore, the underlying system is not required to guarantee that memory between initial and maximum will always be available. (Node: to ensure that all requested memory is available set initial and maximum to the same value).


Field Summary
(package private)  java.lang.Runnable logic
          The logic associated with this.
 
Fields inherited from class javax.realtime.ScopedMemory
portal
 
Fields inherited from class javax.realtime.MemoryArea
constant, heap, id, memoryConsumed, nullClassArr, nullMem, nullObjArr, scoped, shadow, size
 
Constructor Summary
LTMemory(long size)
          Creates a LTMemory of the given size.
LTMemory(long initialSizeInBytes, long maxSizeInBytes)
          Create an LTMemory of the given size.
LTMemory(long initialSizeInBytes, long maxSizeInBytes, java.lang.Runnable logic)
          Create an LTMemory of the given size and logic.
LTMemory(javax.realtime.SizeEstimator initial, javax.realtime.SizeEstimator maximum)
          Creates a LTMemory of the given size estimated by two instances of SizeEstimator.
LTMemory(javax.realtime.SizeEstimator initial, javax.realtime.SizeEstimator maximum, java.lang.Runnable logic)
          Creates a LTMemory of the given size estimated by two instances of SizeEstimator and logic.
 
Method Summary
 void done()
          Invoke this method when you're finished with the MemoryArea (could be a finalizer if we had finalizers...)
private  void doneNative()
          This will actually free the memory (if refcount = 0).
 long getMaximumSize()
          Gets the maximum allowable size for this.
protected  void initNative(long sizeInBytes)
          This constructs a LTMemory of the appropriate size (the maximum allowed to be allocated in the scope).
private  void initNative(long minimum, long maximum)
          Initialize the native component of this MemoryArea (set up the MemBlock)
 java.lang.String toString()
          Prints the string "LTMemory".
 
Methods inherited from class javax.realtime.ScopedMemory
checkAccess, checkNewInstance, enter, enter, getOuterScope, getPortal, getReferenceCount, join, join, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, setPortal, setupMemBlock
 
Methods inherited from class javax.realtime.MemoryArea
bless, enterMemBlock, executeInArea, exitMemBlock, getMemoryArea, memoryConsumed, memoryRemaining, newArray, newArray, newArray, newArray, newInstance, newInstance, newInstance, newInstance, postSetup, preSetup, registerFinal, shadow, size, startMem, stopMem, throwIllegalAssignmentError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logic

java.lang.Runnable logic
The logic associated with this.

Constructor Detail

LTMemory

public LTMemory(long initialSizeInBytes,
                long maxSizeInBytes)
Create an LTMemory of the given size.

Parameters:
initialSizeInBytes - The size in bytes of the memory to allocate for this area. This memory must be committed before the completion of the constructor.
maxSizeInBytes - The size in bytes of the memory to allocate for this area.

LTMemory

public LTMemory(long initialSizeInBytes,
                long maxSizeInBytes,
                java.lang.Runnable logic)
Create an LTMemory of the given size and logic.

Parameters:
initialSizeInBytes - The size in bytes of the memory to allocate for this area. This memory must be committed before the completion of the constructor.
maxSizeInBytes - The size in bytes of the memory to allocate for this area.
logic - The run() method of the given Runnable will be executed using this as its initial memory area.

LTMemory

public LTMemory(javax.realtime.SizeEstimator initial,
                javax.realtime.SizeEstimator maximum)
Creates a LTMemory of the given size estimated by two instances of SizeEstimator.

Parameters:
initial - An instance of SizeEstimator used to give an estimate of the initial size. This memory must be committed before the completion of the constructor.
maximum - An instance of SizeEstimator used to give an estimate for the maximum bytes to allocate for this area.

LTMemory

public LTMemory(javax.realtime.SizeEstimator initial,
                javax.realtime.SizeEstimator maximum,
                java.lang.Runnable logic)
Creates a LTMemory of the given size estimated by two instances of SizeEstimator and logic.

Parameters:
initial - An instance of SizeEstimator used to give an estimate of the initial size. This memory must be committed before the completion of the constructor.
maximum - An instance of SizeEstimator used to give an estimate for the maximum bytes to allocate for this area.
logic - The run() of the given Runnable will be executed using this as its initial memory area.

LTMemory

public LTMemory(long size)
Creates a LTMemory of the given size.

Method Detail

initNative

protected void initNative(long sizeInBytes)
This constructs a LTMemory of the appropriate size (the maximum allowed to be allocated in the scope). The performance hit of allocating a large block of memory is taken when this constructor is called.

Specified by:
initNative in class MemoryArea

getMaximumSize

public long getMaximumSize()
Gets the maximum allowable size for this.

Overrides:
getMaximumSize in class ScopedMemory
Returns:
The maximum size for this

toString

public java.lang.String toString()
Prints the string "LTMemory".

Overrides:
toString in class ScopedMemory
Returns:
The string "LTMemory".

initNative

private void initNative(long minimum,
                        long maximum)
Initialize the native component of this MemoryArea (set up the MemBlock)


done

public void done()
Invoke this method when you're finished with the MemoryArea (could be a finalizer if we had finalizers...)


doneNative

private void doneNative()
This will actually free the memory (if refcount = 0).