javax.realtime
Class LTMemory

java.lang.Object
  extended by javax.realtime.MemoryArea
      extended by javax.realtime.ScopedMemory
          extended by javax.realtime.LTMemory

public class LTMemory
extends ScopedMemory

LTMemory represents a memory area guaranteed by the system to have linear time allocation when memory consumption from the memory area is less than the memory area's initial size. Execution time for allocation is allowed to vary when memory consumption is between the initial size and the maximum size for the area. Furthermore, the underlying system is not required to guarantee that memory between initial and maximum will always be available.

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 initial memory area associated with a NoHeapRealtimeThread, or to enter the memory area using the ScopedMemory.enter() method within a NoHeapRealtimeThread.

Enough memory must be committed by the completion of the constructor to satisfy the initial memory 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 succeed 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: to ensure that all requested memory is available set initial and maximum to the same value)

Methods from LTMemory should be overridden only by methods that use super.

See Also:
MemoryArea, ScopedMemory, RealtimeThread, NoHeapRealtimeThread

Constructor Summary
LTMemory(long size)
          Create an LTMemory of the given size.
LTMemory(long initial, long maximum)
          Create an LTMemory of the given size.
LTMemory(long initial, long maximum, java.lang.Runnable logic)
          Create an LTMemory of the given size.
LTMemory(long size, java.lang.Runnable logic)
          Create an LTMemory of the given size.
LTMemory(SizeEstimator size)
          Create an LTMemory of the given size.
LTMemory(SizeEstimator size, java.lang.Runnable logic)
          Create an LTMemory of the given size.
LTMemory(SizeEstimator initial, SizeEstimator maximum)
          Create an LTMemory of the given size.
LTMemory(SizeEstimator initial, SizeEstimator maximum, java.lang.Runnable logic)
          Create an LTMemory of the given size.
 
Method Summary
 java.lang.String toString()
          Create a string representation of this object.
 
Methods inherited from class javax.realtime.ScopedMemory
enter, enter, executeInArea, getMaximumSize, getPortal, getReferenceCount, join, join, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, newArray, newInstance, newInstance, setPortal
 
Methods inherited from class javax.realtime.MemoryArea
getMemoryArea, memoryConsumed, memoryRemaining, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LTMemory

public LTMemory(long initial,
                long maximum)
Create an LTMemory of the given size.

Parameters:
initial - The size in bytes of the memory to allocate for this area. This memory must be committed before the completion of the constructor.
maximum - The size in bytes of the memory to allocate for this area.
Throws:
java.lang.IllegalArgumentException - Thrown if initial is greater than maximum, or if initial or maximum is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.

LTMemory

public LTMemory(long initial,
                long maximum,
                java.lang.Runnable logic)
Create an LTMemory of the given size.

Parameters:
initial - The size in bytes of the memory to allocate for this area. This memory must be committed before the completion of the constructor.
maximum - The size in bytes of the memory to allocate for this area.
logic - The run() of the given Runnable will be executed using this as its initial memory area. If logic is null, this constructor is equivalent to LTMemory(long initial, long maximum).
Throws:
java.lang.IllegalArgumentException - Thrown if initial is greater than maximum, or if initial or maximum is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.
IllegalAssignmentError - Thrown if storing logic in this would violate the assignment rules.

LTMemory

public LTMemory(SizeEstimator initial,
                SizeEstimator maximum)
Create an LTMemory of the given size.

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.
Throws:
java.lang.IllegalArgumentException - Thrown if initial is null, maximum is null, initial.getEstimate() is greater than maximum.getEstimate(), or if initial.getEstimate() is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.

LTMemory

public LTMemory(SizeEstimator initial,
                SizeEstimator maximum,
                java.lang.Runnable logic)
Create an LTMemory of the given size.

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. If logic is null, this constructor is equivalent to LTMemory(SizeEstimator initial, SizeEstimator maximum).
Throws:
java.lang.IllegalArgumentException - Thrown if initial is null, maximum is null, initial.getEstimate() is greater than maximum.getEstimate(), or if initial.getEstimate() is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.
IllegalAssignmentError - Thrown if storing logic in this would violate the assignment rules.

LTMemory

public LTMemory(long size)
Create an LTMemory of the given size. This constructor is equivalent to LTMemory(size, size)

Parameters:
size - The size in bytes of the memory to allocate for this area. This memory must be committed before the completion of the constructor.
Throws:
java.lang.IllegalArgumentException - Thrown if size is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.
Since:
1.0.1

LTMemory

public LTMemory(long size,
                java.lang.Runnable logic)
Create an LTMemory of the given size. This constructor is equivalent to LTMemory(size, size, logic).

Parameters:
size - The size in bytes of the memory to allocate for this area. This memory must be committed before the completion of the constructor.
logic - The run() of the given Runnable will be executed using this as its initial memory area. If logic is null, this constructor is equivalent to LTMemory(long size).
Throws:
java.lang.IllegalArgumentException - Thrown if size is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.
IllegalAssignmentError - Thrown if storing logic in this would violate the assignment rules.
Since:
1.0.1

LTMemory

public LTMemory(SizeEstimator size)
Create an LTMemory of the given size. This constructor is equivalent to LTMemory(size, size).

Parameters:
size - An instance of SizeEstimator used to give an estimate of the initial size. This memory must be committed before the completion of the constructor.
Throws:
java.lang.IllegalArgumentException - Thrown if size is null, or size.getEstimate() is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.
Since:
1.0.1

LTMemory

public LTMemory(SizeEstimator size,
                java.lang.Runnable logic)
Create an LTMemory of the given size.

Parameters:
size - An instance of SizeEstimator used to give an estimate of the initial size. This memory must be committed before the completion of the constructor.
logic - The run() of the given Runnable will be executed using this as its initial memory area. If logic is null, this constructor is equivalent to LTMemory(SizeEstimator initial).
Throws:
java.lang.IllegalArgumentException - Thrown if size is null, or size.getEstimate() is less than zero.
java.lang.OutOfMemoryError - Thrown if there is insufficient memory for the LTMemory object or for the backing memory.
IllegalAssignmentError - Thrown if storing logic in this would violate the assignment rules.
Since:
1.0.1
Method Detail

toString

public java.lang.String toString()
Create a string representation of this object. The string is of the form
 (LTMemory) Scoped memory # num 
 
where num uniquely identifies the LTMemory area.

Overrides:
toString in class ScopedMemory
Returns:
A string representing the value of this.