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 AsyncBaseEventHandler with no-heap set to true.
In JamaicaVM, application code is not permitted to create instances of user-defined direct subclasses of ScopedMemory.
memoryAreaHeapLock
Modifier | Constructor and Description |
---|---|
|
ScopedMemory(long size)
Constructor to create an instance of ScopedMemory with the given
initial size.
|
protected |
ScopedMemory(long backingMemorySize,
long containerSize,
java.lang.Runnable logic)
Constructor for a memory area with given backing memory and container
sizes for stacked memory, also sets a logic.
|
|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
clearMemory, createStackedMemory, freeStacked, getMemoryArea, memoryConsumed, memoryNeedsToBeCleared, memoryNeedsToBeFreed, memoryRemaining, newArray, newInstance, newInstance, size
public ScopedMemory(long size)
Constructor to create an instance of ScopedMemory with the given initial size.
size
- The size of the memory area in bytes.java.lang.IllegalArgumentException
- if size < 0java.lang.OutOfMemoryError
- if there is insufficient free memory on
the heap.public ScopedMemory(long size, java.lang.Runnable logic)
Constructor to create an instance of ScopedMemory with the given initial size and default logic.
size
- The size of the memory area in bytes.logic
- The default logic to be executed on a call to
enter().java.lang.IllegalArgumentException
- if size < 0java.lang.OutOfMemoryError
- if there is insufficient free memory on
the heap.protected ScopedMemory(long backingMemorySize, long containerSize, java.lang.Runnable logic)
backingMemorySize
- size of the stacked memory scope.containerSize
- size of the stacked memory backing memory, set to 0
for stacked memory guests.logic
- the logic to be associated with this memory
area. May be null not to set a default logic.java.lang.IllegalArgumentException
- if backingMemorySize < 0 or
containerSize < 0java.lang.OutOfMemoryError
- if there is not sufficient memory
available for the new MemoryArea.StackedMemory
public ScopedMemory(SizeEstimator size)
Constructor to create an instance of ScopedMemory with the given initial size.
size
- an instance of SizeEstimator that determines the size
of the memory area.java.lang.IllegalArgumentException
- if size == nulljava.lang.OutOfMemoryError
- if there is insufficient free memory on
the heap.public ScopedMemory(SizeEstimator size, java.lang.Runnable logic)
Constructor to create an instance of ScopedMemory with the given initial size and default logic.
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().java.lang.IllegalArgumentException
- if size == nulljava.lang.OutOfMemoryError
- if there is insufficient free memory on
the heap.public void enter() throws ScopedCycleException
enter
in class MemoryArea
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.public void enter(java.lang.Runnable logic) throws ScopedCycleException
enter
in class MemoryArea
logic
- the code to be executed in this memory area.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.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.
public java.lang.Object getPortal() throws MemoryAccessError, IllegalAssignmentError
IllegalAssignmentError
- if portal cannot be assigned to
the current memory area.MemoryAccessError
public void setPortal(java.lang.Object object)
object
- the new portal.IllegalAssignmentError
- if object cannot be assigned to an
object stored in this memory area.InaccessibleAreaException
- if this is not on the scope
stack.public int getReferenceCount()
public ScopedMemory getParent()
public java.lang.String toString()
toString
in class java.lang.Object
public void join(HighResolutionTime time) throws java.lang.InterruptedException
time
- An absolute or relative deadline for the wait.java.lang.InterruptedException
- if wait is interrupted by
Thread.interrupt() or AsynchronouslyInterruptedException.fire().java.lang.IllegalArgumentException
- if time is null.public void join() throws java.lang.InterruptedException
java.lang.InterruptedException
- if wait is interrupted by
Thread.interrupt() or AsynchronouslyInterruptedException.fire().public void joinAndEnter() throws java.lang.InterruptedException
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.public void joinAndEnter(HighResolutionTime time) throws java.lang.InterruptedException
time
- An absolute or relative deadline for the wait.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.public void joinAndEnter(java.lang.Runnable logic) throws java.lang.InterruptedException
logic
- the code to be executed in this memory area.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.public void joinAndEnter(java.lang.Runnable logic, HighResolutionTime time) throws java.lang.InterruptedException
logic
- the code to be executed in this memory area.time
- An absolute or relative deadline for the wait.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.public void executeInArea(java.lang.Runnable logic) throws InaccessibleAreaException
executeInArea
in class MemoryArea
logic
- the logic whose run method is to be executed in this
memory area.InaccessibleAreaException
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2016 aicas GmbH. All Rights Reserved.