javax.realtime.memory
@Deprecated public class ScopedMemory extends MemoryArea
ScopedMemory
.Modifier | Constructor and Description |
---|---|
|
ScopedMemory(long sizeInBytes)
Deprecated.
Equivalent to
ScopedMemory(long, Runnable) with the argument list
(size, null) . |
|
ScopedMemory(long sizeInBytes,
java.lang.Runnable logic)
Deprecated.
Creates a new
ScopedMemory area with the given parameters. |
protected |
ScopedMemory(SizeEstimator size)
Deprecated.
Equivalent to
ScopedMemory(long, Runnable) with the argument list
(size.getEstimate(), null) . |
|
ScopedMemory(SizeEstimator size,
java.lang.Runnable logic)
Deprecated.
Equivalent to
ScopedMemory(long, Runnable) with the argument list
(size.getEstimate(), logic) . |
Modifier and Type | Method and Description |
---|---|
void |
enter()
Deprecated.
Associates this memory area with the current schedulable for the duration
of the execution of the
run() method of the instance of
Runnable given in the constructor. |
void |
enter(java.lang.Runnable logic)
Deprecated.
Associates this memory area with the current schedulable for the duration
of the execution of the
run() method of the given Runnable . |
void |
executeInArea(java.lang.Runnable logic)
Deprecated.
Executes the run method from the
logic parameter using this memory
area as the current allocation context. |
long |
getMaximumSize()
Deprecated.
Gets the maximum size this memory area can attain.
|
java.lang.Object |
getPortal()
Deprecated.
Obtains a reference to the portal object in this instance of
ScopedMemory . |
int |
getReferenceCount()
Deprecated.
Returns the reference count of this
ScopedMemory . |
void |
join()
Deprecated.
Waits until the reference count of this
ScopedMemory goes down to
zero. |
void |
join(HighResolutionTime<?> time)
Deprecated.
Waits at most until the time designated by the
time parameter for
the reference count of this ScopedMemory to drop to zero. |
void |
joinAndEnter()
Deprecated.
In the error-free case,
joinAndEnter() combines
join();enter(); such that no enter() from another
schedulable can intervene between the two method invocations. |
void |
joinAndEnter(HighResolutionTime<?> time)
Deprecated.
In the error-free case,
joinAndEnter() combines
join();enter(); such that no enter() from
another schedulable can intervene between the two method invocations. |
void |
joinAndEnter(java.lang.Runnable logic)
Deprecated.
In the error-free case,
joinAndEnter() combines
join();enter(); such that no enter() from another
schedulable can intervene between the two method invocations. |
void |
joinAndEnter(java.lang.Runnable logic,
HighResolutionTime<?> time)
Deprecated.
In the error-free case,
joinAndEnter() combines
join();enter(); such that no enter() from another
schedulable can intervene between the two method invocations. |
long |
memoryConsumed()
Deprecated.
For memory areas where memory is freed under program control this returns
an exact count, in bytes, of the memory currently used by the system for
the allocated objects.
|
long |
memoryRemaining()
Deprecated.
An approximation of the total amount of memory currently
available for future allocated objects, measured in bytes.
|
java.lang.Object |
newArray(java.lang.Class<?> type,
int number)
Deprecated.
Allocates an array of the given type in this memory area.
|
java.lang.Object |
newInstance(java.lang.Class<?> type)
Deprecated.
Allocates an object in this memory area.
|
java.lang.Object |
newInstance(java.lang.reflect.Constructor<?> c,
java.lang.Object[] args)
Deprecated.
Allocates an object in this memory area.
|
void |
setPortal(java.lang.Object portal)
Deprecated.
Sets the portal object of the memory area represented by this
instance of
ScopedMemory to the given object. |
long |
size()
Deprecated.
Queries the size of the memory area.
|
java.lang.String |
toString()
Deprecated.
Returns a user-friendly representation of this
ScopedMemory of the
form ScopedMemory#<num> where <num> is a number that
uniquely identifies this scoped memory area. |
getMemoryArea
public ScopedMemory(long sizeInBytes)
ScopedMemory(long, Runnable)
with the argument list
(size, null)
.sizeInBytes
- of the new ScopedMemory
area in bytes.java.lang.IllegalArgumentException
- when size
is less than zero.java.lang.OutOfMemoryError
- when there is insufficient memory for the
ScopedMemory
object or for the
backing memory.protected ScopedMemory(SizeEstimator size)
ScopedMemory(long, Runnable)
with the argument list
(size.getEstimate(), null)
.size
- The size of the new ScopedMemory
area estimated by an
instance of SizeEstimator
.java.lang.IllegalArgumentException
- when size
is null
, or
size.getEstimate()
is negative.java.lang.OutOfMemoryError
- when there is insufficient memory for the
ScopedMemory
object or for the
backing memory.public ScopedMemory(SizeEstimator size, java.lang.Runnable logic)
ScopedMemory(long, Runnable)
with the argument list
(size.getEstimate(), logic)
.size
- The size of the new ScopedMemory
area estimated by an
instance of SizeEstimator
.logic
- The logic which will use the memory represented by this
as its initial memory area. When logic
is null
, this constructor is equivalent to constructing the
memory area without a logic value.java.lang.IllegalArgumentException
- when size
is null
, or
size.getEstimate()
is negative.java.lang.OutOfMemoryError
- when there is insufficient memory for the
ScopedMemory
object or for the
backing memory.IllegalAssignmentError
- when storing logic
in this
would violate the assignment rules.public ScopedMemory(long sizeInBytes, java.lang.Runnable logic)
ScopedMemory
area with the given parameters.sizeInBytes
- The size of the new ScopedMemory
area in bytes.logic
- The Runnable
to execute when this ScopedMemory
is entered. When logic
is null
, this constructor is equivalent to constructing
the memory area without a logic value.java.lang.IllegalArgumentException
- when size
is less than zero.IllegalAssignmentError
- when storing logic
in this
would violate the assignment
rules.java.lang.OutOfMemoryError
- when there is insufficient memory for
the ScopedMemory
object or
for the backing memory.java.lang.UnsupportedOperationException
- In JamaicaVM when a user-defined
subclass does not know about the
memory area implementation details.public void enter()
run()
method of the instance of
Runnable
given in the constructor. During this period of execution,
this memory area becomes the default allocation context until another
default allocation context is selected (using enter()
, or
#executeInArea()
) or the enter()
method exits.enter
in class MemoryArea
ScopedCycleException
- when this invocation would break the
single parent rule.ThrowBoundaryError
- when the JVM needs to propagate an
exception allocated in this
scope to (or through) the memory area
of the caller. Storing a reference to
that exception would cause an IllegalAssignmentError
, so the JVM
cannot be permitted to deliver the
exception. The ThrowBoundaryError
is allocated in the current allocation
context and contains information about
the exception it replaces.java.lang.IllegalThreadStateException
- when the caller is a Java thread, or
when this method is invoked during
finalization of objects in scoped
memory and entering this scoped memory
area would force deletion of the SO
that triggered finalization. This
would include the scope containing the
SO, and the scope (if any) containing
the scope containing the SO.java.lang.IllegalArgumentException
- when the caller is a schedulable
and a null
value for
logic
was supplied when
the memory area was constructed.MemoryAccessError
- when caller is a schedulable that
may not use the heap and this
memory area's logic value is
allocated in heap memory.public void enter(java.lang.Runnable logic)
run()
method of the given Runnable
.
During this period of execution, this memory area becomes the default
allocation context until another default allocation context is selected
(using enter()
, or executeInArea()
) or the enter()
method exits.enter
in class MemoryArea
logic
- The Runnable object whose run()
method should be
invoked.ScopedCycleException
- when this invocation would break the
single parent rule.ThrowBoundaryError
- when the JVM needs to propagate an
exception allocated in this
scope to (or through) the memory area
of the caller. Storing a reference to
that exception would cause an IllegalAssignmentError
, so the JVM
cannot be permitted to deliver the
exception. The ThrowBoundaryError
is allocated in the current allocation
context and contains information about
the exception it replaces.java.lang.IllegalThreadStateException
- when the caller is a Java thread, or
when this method is invoked during
finalization of objects in scoped
memory and entering this scoped memory
area would force deletion of the SO
that triggered finalization. This
would include the scope containing the
SO, and the scope (if any) containing
the scope containing the SO.java.lang.IllegalArgumentException
- when the caller is a schedulable
and logic
is null
.public long memoryConsumed()
MemoryArea
In JamaicaVM, the memoryConsumed() for HeapMemory is amount of allocated (i.e., non-free) memory. It is an upper bound for the amount of reachable memory.
memoryConsumed
in class MemoryArea
public long memoryRemaining()
MemoryArea
In JamaicaVM, memoryRemaining for HeapMemory is the total heap memory minus memoryConsumed().
memoryRemaining
in class MemoryArea
public long size()
MemoryArea
size
in class MemoryArea
public java.lang.Object newInstance(java.lang.Class<?> type) throws java.lang.IllegalAccessException, java.lang.InstantiationException
newInstance
in class MemoryArea
type
- the type of the new object that is to be allocated.java.lang.IllegalAccessException
- thrown if class or constructor is
inaccessible.java.lang.IllegalArgumentException
- iff type is null.java.lang.ExceptionInInitializerError
- iff initialization of class
type caused an exception.java.lang.OutOfMemoryError
- iff the space in this memory area is exhaustedjava.lang.InstantiationException
- if object could not be
instantiated (due to type being abstract or an interface or the
constructor caused an exception)java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.InaccessibleAreaException
- when the memory area is not in the
schedulable's scope stack.public java.lang.Object newInstance(java.lang.reflect.Constructor<?> c, java.lang.Object[] args) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
newInstance
in class MemoryArea
c
- the constructor of the new instanceargs
- the arguments to be passed to the constructorjava.lang.IllegalAccessException
- thrown if type is inaccessiblejava.lang.InstantiationException
- if object could not be
instantiated (due to type being abstract or an interface or the
constructor caused an exception)java.lang.OutOfMemoryError
- iff the space in this memory area is exhaustedjava.lang.IllegalArgumentException
- iff c is null or args does not
contain the number of arguments required by c (args may be null
if the arguments list is empty).java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.java.lang.reflect.InvocationTargetException
InaccessibleAreaException
- when the memory area is not in the
schedulable's scope stack.public java.lang.Object newArray(java.lang.Class<?> type, int number) throws java.lang.IllegalArgumentException, java.lang.OutOfMemoryError, InaccessibleAreaException
newArray
in class MemoryArea
type
- The class of the elements of the new array. To create an
array of a primitive type use a type
such as Integer.TYPE
(which would call for an array of the primitive
int type.)number
- The number of elements in the new array.java.lang.IllegalArgumentException
- when number
is less than zero,
type
is null
, or type
is java.lang.Void.TYPE
.java.lang.OutOfMemoryError
- when space in the memory area is
exhausted.java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.InaccessibleAreaException
- when the memory area is not in the
schedulable's scope stack.public void executeInArea(java.lang.Runnable logic) throws InaccessibleAreaException
logic
parameter using this memory
area as the current allocation context. This method behaves as if it moves
the allocation context down the scope stack to the occurrence of
this
.executeInArea
in class MemoryArea
logic
- The runnable object whose run()
method should be
executed.java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.InaccessibleAreaException
- when the memory area is not in the
schedulable's scope stack.java.lang.IllegalArgumentException
- when the caller is a schedulable and
logic
is null
.public long getMaximumSize()
JamaicaVM does not support growing memory areas, i.e., the maximum size is always equal to the size.
public java.lang.Object getPortal()
ScopedMemory
.
Assignment rules are enforced on the value returned by getPortal()
as if the return value were first stored in an object allocated in the
current allocation context, then moved to its final destination.
null
when there is no
portal object. The portal value is always set to null
when the
contents of the memory are deleted.IllegalAssignmentError
- when a reference to the portal object
cannot be stored in the caller's
allocation context; that is, when
this
is "inner" relative to the
current allocation context or not on
the caller's scope stack.java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.public void setPortal(java.lang.Object portal)
ScopedMemory
to the given object. The object must have
been allocated in this ScopedMemory
instance.portal
- The object which will become the portal for this. When null
the previous portal object remains the portal object
for this or when there was no previous portal object then
there is still no portal object for this
.java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.IllegalAssignmentError
- when the caller is a schedulable, and
object
is not allocated in this
scoped memory instance and not null
.InaccessibleAreaException
- when the caller is a schedulable,
this
memory area is not in the
caller's scope stack and object
is not null
.public int getReferenceCount()
ScopedMemory
.
Note that a reference count of 0 reliably means that the scope is not referenced, but other reference counts are subject to artifacts of lazy/eager maintenance by the implementation.
ScopedMemory
.public void join() throws java.lang.InterruptedException
ScopedMemory
goes down to
zero. Returns immediately when the memory is unreferenced.java.lang.InterruptedException
- When this schedulable is interrupted by
RealtimeThread.interrupt()
or
AsynchronouslyInterruptedException.fire()
while waiting for the reference count
to go to zero.java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.public void join(HighResolutionTime<?> time) throws java.lang.InterruptedException
time
parameter for
the reference count of this ScopedMemory
to drop to zero. Returns
immediately when the memory area is unreferenced.
Since the time is expressed as a HighResolutionTime
, this method is
an accurate timer with nanosecond granularity. The actual resolution of the
timer and even the quantity it measures depends on the clock associated
with time
. The delay time may be relative or absolute. When
relative, then the delay is the amount of time given by time
, and
measured by its associated clock. When absolute, then the delay is until
the indicated value is reached by the clock. When the given absolute time
is less than or equal to the current value of the clock, the call to
join()
returns immediately.
time
- When this time is an absolute time, the wait is bounded by that
point in time. When the time is a relative time, the wait is
bounded by a the specified interval from some time between the
time join
is called and the time it starts waiting for
the reference count to reach zero.java.lang.InterruptedException
- When this schedulable is interrupted
by RealtimeThread.interrupt()
or AsynchronouslyInterruptedException.fire()
while waiting for the reference count
to go to zero.java.lang.IllegalThreadStateException
- when the caller context in not an
instance of Schedulable
.java.lang.IllegalArgumentException
- when the caller is a schedulable and
time
is null
.java.lang.UnsupportedOperationException
- when the wait operation is not
supported using the clock associated
with time
.public void joinAndEnter() throws java.lang.InterruptedException
joinAndEnter()
combines
join();enter();
such that no enter()
from another
schedulable can intervene between the two method invocations. The resulting
method will wait for the reference count on this ScopedMemory
to
reach zero, then enter the ScopedMemory
and execute the
run()
method from logic
passed in the constructor. When no
instance of Runnable
was passed to the memory area's constructor,
the method throws IllegalArgumentException
immediately.
When multiple threads are waiting in joinAndEnter()
family methods
for a memory area, at most one of them will be released each time
the reference count goes to zero.
Note that although joinAndEnter()
guarantees that the reference
count is zero when the schedulable is released for entry, it does not
guarantee that the reference count will remain one for any length of time.
A subsequent enter()
could raise the reference count to two.
java.lang.InterruptedException
- When this schedulable is interrupted by
RealtimeThread.interrupt()
or
AsynchronouslyInterruptedException.fire()
while waiting for the reference count
to go to zero.java.lang.IllegalThreadStateException
- when the caller is a Java thread, or
when this method is invoked during
finalization of objects in scoped
memory and entering this scoped memory
area would force deletion of the SO
that triggered finalization. This
would include the scope containing the
SO, and the scope (if any) containing
the scope containing the SO.ThrowBoundaryError
- when the JVM needs to propagate an
exception allocated in this
scope to (or through) the memory area
of the caller. Storing a reference to
that exception would cause an IllegalAssignmentError
, so the JVM
cannot be permitted to deliver the
exception. The ThrowBoundaryError
is allocated in the current allocation
context and contains information about
the exception it replaces.ScopedCycleException
- when this invocation would break the
single parent rule.java.lang.IllegalArgumentException
- when the caller is a schedulable and no
non-null logic
value was
supplied to the memory area's
constructor.MemoryAccessError
- when caller is a non-heap schedulable
and this memory area's logic value is
allocated in heap memory.public void joinAndEnter(HighResolutionTime<?> time) throws java.lang.InterruptedException
joinAndEnter()
combines
join();enter();
such that no enter()
from
another schedulable can intervene between the two method invocations.
The resulting method will wait for the reference count on this
ScopedMemory
to reach zero, or for the current time to reach the
designated time, then enter the ScopedMemory
and execute the
run()
method from Runnable
object passed to the constructor.
When no instance of Runnable
was passed to the memory area's
constructor, the method throws IllegalArgumentException
immediately.
When multiple threads are waiting in joinAndEnter
family methods
for a memory area, at most one of them will be released each time
the reference count goes to zero.
Since the time is expressed as a HighResolutionTime
, this method
has an accurate timer with nanosecond granularity. The actual resolution of
the timer and even the quantity it measures depends on the clock associated
with time
. The delay time may be relative or absolute.
When relative, then the calling thread is blocked for at most the amount of
time given by time
, and measured by its associated clock.
When absolute, then the time delay is until the indicated value is reached
by the clock. When the given absolute time is less than or equal to the
current value of the clock, the call to joinAndEnter
behaves
effectively like enter()
.
Note that expiration of time
may cause control to enter the memory
area before its reference count has gone to zero.
time
- The time that bounds the wait.ThrowBoundaryError
- when the JVM needs to propagate an
exception allocated in this
scope to (or through) the memory area
of the caller. Storing a reference to
that exception would cause an IllegalAssignmentError
, so the JVM
cannot be permitted to deliver the
exception. The ThrowBoundaryError
is allocated in the current
allocation context and contains
information about the exception it
replaces.java.lang.InterruptedException
- When this schedulable is interrupted
by RealtimeThread.interrupt()
or AsynchronouslyInterruptedException.fire()
while waiting for the reference count
to go to zero.java.lang.IllegalThreadStateException
- when the caller context is not an
instance of Schedulable
, or
when this method is invoked during
finalization of objects in scoped
memory and entering this scoped
memory area would force deletion of
the instance that triggered
finalization. This would include the
scope containing the instance, and
the scope (if any) containing the
scope containing the instance.ScopedCycleException
- when the caller is a schedulable and
this invocation would break the
single parent rule.java.lang.IllegalArgumentException
- when the caller is a schedulable, and
time
is null
or
null
was supplied as logic
value to the memory area's
constructor.java.lang.UnsupportedOperationException
- when the wait operation is not
supported using the clock associated
with time
.MemoryAccessError
- when the calling schedulable may not
use the heap and this memory area's
logic value is allocated in heap
memory.public void joinAndEnter(java.lang.Runnable logic) throws java.lang.InterruptedException
joinAndEnter()
combines
join();enter();
such that no enter()
from another
schedulable can intervene between the two method invocations. The resulting
method will wait for the reference count on this ScopedMemory
to
reach zero, then enter the ScopedMemory
and execute the run
method from logic
When logic
is null
, throw IllegalArgumentException
immediately.
When multiple threads are waiting in joinAndEnter
family methods
for a memory area, at most one of them will be released each time
the reference count goes to zero.
Note that although joinAndEnter()
guarantees that the reference count
is zero when the schedulable is released for entry, it does not guarantee
that the reference count will remain one for any length of time.
A subsequent enter()
could raise the reference count to two.
logic
- The Runnable
object which contains the code to
execute.java.lang.InterruptedException
- When this schedulable is interrupted by
RealtimeThread.interrupt()
or
AsynchronouslyInterruptedException.fire()
while waiting for the reference count
to go to zero.java.lang.IllegalThreadStateException
- when the caller is a Java thread, or
when this method is invoked during
finalization of objects in scoped
memory and entering this scoped memory
area would force deletion of the SO
that triggered finalization. This
would include the scope containing the
SO, and the scope (if any) containing
the scope containing the SO.ThrowBoundaryError
- when the JVM needs to propagate an
exception allocated in this
scope to (or through) the memory area
of the caller. Storing a reference to
that exception would cause an IllegalAssignmentError
, so the JVM
cannot be permitted to deliver the
exception. The ThrowBoundaryError
is allocated in the current allocation
context and contains information about
the exception it replaces.ScopedCycleException
- when this invocation would break the
single parent rule.java.lang.IllegalArgumentException
- when the caller is a schedulable and
logic
is null
.public void joinAndEnter(java.lang.Runnable logic, HighResolutionTime<?> time) throws java.lang.InterruptedException
joinAndEnter()
combines
join();enter();
such that no enter()
from another
schedulable can intervene between the two method invocations. The resulting
method will wait for the reference count on this ScopedMemory
to
reach zero, or for the current time to reach the designated time, then
enter the ScopedMemory
and execute the run
method from
logic
.
Since the time is expressed as a HighResolutionTime
, this method is
an accurate timer with nanosecond granularity. The actual resolution of the
timer and even the quantity it measures depends on the clock associated
with time
. The delay time may be relative or absolute.
When relative, then the delay is the amount of time given by time
,
and measured by its associated clock. When absolute, then the delay is
until the indicated value is reached by the clock. When the given absolute
time is less than or equal to the current value of the clock, the call to
joinAndEnter
behaves effectively like enter(Runnable)
.
Throws IllegalArgumentException
immediately when logic
is
null
.
When multiple threads are waiting in joinAndEnter
family methods
for a memory area, at most one of them will be released each time
the reference count goes to zero.
Note that expiration of time
may cause control to enter the memory
area before its reference count has gone to zero.
logic
- The Runnable
object which contains the code to
execute.time
- The time that bounds the wait.java.lang.InterruptedException
- When this schedulable is interrupted
by RealtimeThread.interrupt()
or AsynchronouslyInterruptedException.fire()
while waiting for the reference count
to go to zero.java.lang.IllegalThreadStateException
- when the execution context in not an
instance of Schedulable
, or
when this method is invoked during
finalization of objects in scoped
memory and entering this scoped
memory area would force deletion of
the task that triggered finalization.
This would include the scope
containing the task, and the scope
(if any) containing the scope
containing the task.ThrowBoundaryError
- when the JVM needs to propagate an
exception allocated in this
scope to (or through) the memory area
of the caller. Storing a reference to
that exception would cause an IllegalAssignmentError
, so the JVM
cannot be permitted to deliver the
exception. The ThrowBoundaryError
is allocated in the current
allocation context and contains
information about the exception it
replaces.ScopedCycleException
- when the caller is a schedulable and
this invocation would break the
single parent rule.java.lang.IllegalArgumentException
- when the caller is a schedulable and
time
or logic
is
null
.java.lang.UnsupportedOperationException
- when the wait operation is not
supported using the clock associated
with time
.public java.lang.String toString()
ScopedMemory
of the
form ScopedMemory#<num>
where <num>
is a number that
uniquely identifies this scoped memory area.toString
in class java.lang.Object
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2017 aicas GmbH. All Rights Reserved.