aicas logoJamaica 6.1 release 1

javax.realtime
Class ScopedMemory

java.lang.Object
  extended by javax.realtime.MemoryArea
      extended by javax.realtime.ScopedMemory
Direct Known Subclasses:
LTMemory, LTPhysicalMemory, VTMemory, VTPhysicalMemory

public abstract class ScopedMemory
extends MemoryArea

Jamaica Real-Time Specification for Java class ScopedMemory

A memory area of this type enables region-based memory allocation, i.e., objects allocated in ScopedMemory have a lifetime that ends abruptly when the last schedulable object leaves this memory area.

The memory allocated in scoped memory is not subject to garbage collection. It is hence safe to access this memory from within a NoHeapRealtimeThread or an AsyncEventHandler with no-heap set to true.

In JamaicaVM, application code is not permitted to create instances of user-defined direct subclasses of ScopedMemory.


Constructor Summary
ScopedMemory(long size)
           Constructor to create an instance of ScopedMemory with the given initial size.
ScopedMemory(long size, java.lang.Runnable logic)
           Constructor to create an instance of ScopedMemory with the given initial size and default logic.
ScopedMemory(SizeEstimator size)
           Constructor to create an instance of ScopedMemory with the given initial size.
ScopedMemory(SizeEstimator size, java.lang.Runnable logic)
           Constructor to create an instance of ScopedMemory with the given initial size and default logic.
 
Method Summary
 void enter()
          enter enters this memory area and executes the logic that was passed to this memory area's constructor.
 void enter(java.lang.Runnable logic)
          enter this memory area and execute the given logic.
 void executeInArea(java.lang.Runnable logic)
          executeInArea executes a code sequence given as logic in this memory area.
 long getMaximumSize()
           getMaximumSize returns the maximum size this memory area may grow to.
 ScopedMemory getParent()
          Return the parent memory area, when there is a parent and it is a scoped memory.
 java.lang.Object getPortal()
          getPortal returns a reference to the portal object of this ScopedMemory.
 int getReferenceCount()
          getReferenceCount returns the reference count of this memory area.
 void join()
          join waits for the reference count of this memory area to drop to zero.
 void join(HighResolutionTime time)
          join waits for the reference count of this memory area to drop to zero.
 void joinAndEnter()
          joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().
 void joinAndEnter(HighResolutionTime time)
          joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().
 void joinAndEnter(java.lang.Runnable logic)
          joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().
 void joinAndEnter(java.lang.Runnable logic, HighResolutionTime time)
          joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().
 void setPortal(java.lang.Object object)
          setPortal sets the portal object of this memory area to the argument.
 java.lang.String toString()
          toString creates a string representation of this memory area of the form "Scoped memory # "+num with num being a unique identifier for this memory area.
 
Methods inherited from class javax.realtime.MemoryArea
finalize, getMemoryArea, memoryConsumed, memoryRemaining, newArray, newInstance, newInstance, size
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScopedMemory

public ScopedMemory(long size)

Constructor to create an instance of ScopedMemory with the given initial size.

Parameters:
size - The size of the memory area in bytes.
Throws:
java.lang.IllegalArgumentException - if size < 0
java.lang.OutOfMemoryError - if there is insufficient free memory on the heap.

ScopedMemory

public ScopedMemory(long size,
                    java.lang.Runnable logic)

Constructor to create an instance of ScopedMemory with the given initial size and default logic.

Parameters:
size - The size of the memory area in bytes.
logic - The default logic to be executed on a call to enter().
Throws:
java.lang.IllegalArgumentException - if size < 0
java.lang.OutOfMemoryError - if there is insufficient free memory on the heap.

ScopedMemory

public ScopedMemory(SizeEstimator size)

Constructor to create an instance of ScopedMemory with the given initial size.

Parameters:
size - an instance of SizeEstimator that determines the size of the memory area.
Throws:
java.lang.IllegalArgumentException - if size == null
java.lang.OutOfMemoryError - if there is insufficient free memory on the heap.

ScopedMemory

public ScopedMemory(SizeEstimator size,
                    java.lang.Runnable logic)

Constructor to create an instance of ScopedMemory with the given initial size and default logic.

Parameters:
size - an instance of SizeEstimator that determines the size of the memory area.
logic - The default logic to be executed on a call to enter().
Throws:
java.lang.IllegalArgumentException - if size == null
java.lang.OutOfMemoryError - if there is insufficient free memory on the heap.
Method Detail

enter

public void enter()
           throws ScopedCycleException
enter enters this memory area and executes the logic that was passed to this memory area's constructor.

Overrides:
enter in class MemoryArea
Throws:
ScopedCycleException - if entering this scope has a parent and we enter it from a different parent (i.e., the single parent rule is broken).
ThrowBoundaryError - thrown if an exception is thrown by the logic executed and the exception cannot be propagated out of this scope since that would cause an IllegalAssignmentError. In this case, the exception is replaced by a ThrowBoundaryError.
java.lang.IllegalArgumentException - iff no logic was provided to the constructor or the logic that was provided was null.
java.lang.IllegalStateException - if the caller is a Java thread and -strictRTSJ is set.

enter

public void enter(java.lang.Runnable logic)
           throws ScopedCycleException
enter this memory area and execute the given logic.

Overrides:
enter in class MemoryArea
Parameters:
logic - the code to be executed in this memory area.
Throws:
ScopedCycleException - if entering this scope has a parent and we enter it from a different parent (i.e., the single parent rule is broken).
ThrowBoundaryError - thrown if an exception is thrown by the logic executed and the exception cannot be propagated out of this scope since that would cause an IllegalAssignmentError. In this case, the exception is replaced by a ThrowBoundaryError.
java.lang.IllegalArgumentException - if logic is null.
java.lang.IllegalStateException - iff the caller is a Java thread and -strictRTSJ is set.

getMaximumSize

public long getMaximumSize()

getMaximumSize returns the maximum size this memory area may grow to.

JamaicaVM currently does not support growing memory areas, i.e., the maximum size is always equal to the size.

Returns:
the maximum size this memory area may grow to.

getPortal

public java.lang.Object getPortal()
                           throws MemoryAccessError,
                                  IllegalAssignmentError
getPortal returns a reference to the portal object of this ScopedMemory.

Returns:
the portal object or null if none was set.
Throws:
IllegalAssignmentError - if portal cannot be assigned to the current memory area.
MemoryAccessError - if portal object is in heap and current thread is NoHeapRealtimeThread and -strictRTSJ is set.

setPortal

public void setPortal(java.lang.Object object)
setPortal sets the portal object of this memory area to the argument.

Parameters:
object - the new portal.
Throws:
IllegalAssignmentError - if object cannot be assigned to an object stored in this memory area.
InaccessibleAreaException - if this is not on the scope stack.

getReferenceCount

public int getReferenceCount()
getReferenceCount returns the reference count of this memory area. The reference count is increased whenever this memory area is entered, it is decreased when it is exited.

Returns:
the current reference count.

getParent

public ScopedMemory getParent()
Return the parent memory area, when there is a parent and it is a scoped memory. This means that if the parent scope is immortal or heap, null is returned. This reduces the need for casting the returned value. This method is new in RTSJ 1.1; but in 1.1, the return type will be ScopedAllocationContext, an interface that has not yet been added.

Returns:
null or the parent scope
Since:
RTSJ 1.1

toString

public java.lang.String toString()
toString creates a string representation of this memory area of the form "Scoped memory # "+num with num being a unique identifier for this memory area.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this.

join

public void join(HighResolutionTime time)
          throws java.lang.InterruptedException
join waits for the reference count of this memory area to drop to zero. Do not wait if the reference count is already zero.

Parameters:
time - An absolute or relative deadline for the wait.
Throws:
java.lang.InterruptedException - if wait is interrupted by Thread.interrupt() or AsynchronouslyInterruptedException.fire().
java.lang.IllegalArgumentException - if time is null.

join

public void join()
          throws java.lang.InterruptedException
join waits for the reference count of this memory area to drop to zero. Do not wait if the reference count is already zero.

Throws:
java.lang.InterruptedException - if wait is interrupted by Thread.interrupt() or AsynchronouslyInterruptedException.fire().

joinAndEnter

public void joinAndEnter()
                  throws java.lang.InterruptedException
joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().

Throws:
java.lang.InterruptedException - if wait is interrupted by Thread.interrupt() or AsynchronouslyInterruptedException.fire().
ScopedCycleException - if entering this scope has a parent and we enter it from a different parent (i.e., the single parent rule is broken).
ThrowBoundaryError - thrown if an exception is thrown by the logic executed and the exception cannot be propagated out of this scope since that would cause an IllegalAssignmentError. In this case, the exception is replaced by a ThrowBoundaryError.
java.lang.IllegalArgumentException - if logic is null.
java.lang.IllegalStateException - iff the caller is a Java thread and -strictRTSJ is set.

joinAndEnter

public void joinAndEnter(HighResolutionTime time)
                  throws java.lang.InterruptedException
joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().

Parameters:
time - An absolute or relative deadline for the wait.
Throws:
java.lang.InterruptedException - if wait is interrupted by Thread.interrupt() or AsynchronouslyInterruptedException.fire().
ScopedCycleException - if entering this scope has a parent and we enter it from a different parent (i.e., the single parent rule is broken).
ThrowBoundaryError - thrown if an exception is thrown by the logic executed and the exception cannot be propagated out of this scope since that would cause an IllegalAssignmentError. In this case, the exception is replaced by a ThrowBoundaryError.
java.lang.IllegalArgumentException - if time is null.
java.lang.IllegalStateException - iff the caller is a Java thread and -strictRTSJ is set.

joinAndEnter

public void joinAndEnter(java.lang.Runnable logic)
                  throws java.lang.InterruptedException
joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().

Parameters:
logic - the code to be executed in this memory area.
Throws:
java.lang.InterruptedException - if wait is interrupted by Thread.interrupt() or AsynchronouslyInterruptedException.fire().
ScopedCycleException - if entering this scope has a parent and we enter it from a different parent (i.e., the single parent rule is broken).
ThrowBoundaryError - thrown if an exception is thrown by the logic executed and the exception cannot be propagated out of this scope since that would cause an IllegalAssignmentError. In this case, the exception is replaced by a ThrowBoundaryError.
java.lang.IllegalArgumentException - if logic is null.
java.lang.IllegalStateException - if the caller is a Java thread and -strictRTSJ is set.

joinAndEnter

public void joinAndEnter(java.lang.Runnable logic,
                         HighResolutionTime time)
                  throws java.lang.InterruptedException
joinAndEnter combines join() and enter() such that no other schedulable object may enter() in between the join() and the enter().

Parameters:
logic - the code to be executed in this memory area.
time - An absolute or relative deadline for the wait.
Throws:
java.lang.InterruptedException - if wait is interrupted by Thread.interrupt() or AsynchronouslyInterruptedException.fire().
ScopedCycleException - if entering this scope has a parent and we enter it from a different parent (i.e., the single parent rule is broken).
ThrowBoundaryError - thrown if an exception is thrown by the logic executed and the exception cannot be propagated out of this scope since that would cause an IllegalAssignmentError. In this case, the exception is replaced by a ThrowBoundaryError.
java.lang.IllegalArgumentException - if logic is null or time is null.
java.lang.IllegalStateException - iff the caller is a Java thread and -strictRTSJ is set.

executeInArea

public void executeInArea(java.lang.Runnable logic)
                   throws InaccessibleAreaException
executeInArea executes a code sequence given as logic in this memory area.

Overrides:
executeInArea in class MemoryArea
Parameters:
logic - the logic whose run method is to be executed in this memory area.
Throws:
InaccessibleAreaException

aicas logoJamaica 6.1 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2012 aicas GmbH. All Rights Reserved.