public class PinnableMemory extends ScopedMemory
PinnableMemory
, allocate some data structure, put a reference in the
portal, pin the scope, exit it, and then pass it to another thread for
further processing or consumption. Once the last thread is done, the memory
can be unpinned, causing its contents to be freed.
Creation of a PinnableMemory
shall fail with a
StaticOutOfMemoryError
when the current
Schedulable
has been configured with a
ScopedMemoryParameters.getMaxGlobalBackingStore()
that would be exceeded
by said creation.
Constructor and Description |
---|
PinnableMemory(long size)
Creates a scoped memory of fixed size that can be held open when no
Schedulable has it on its scoped memory stack. |
PinnableMemory(long size,
Runnable logic)
Creates a scoped memory of fixed size that can be held open when no
Schedulable has it on its scoped memory stack. |
PinnableMemory(SizeEstimator size)
Equivalent to
PinnableMemory(long) with
size.getEstimate() as its argument. |
PinnableMemory(SizeEstimator size,
Runnable logic)
Equivalent to
PinnableMemory(long, Runnable) with
size.getEstimate() as its first argument. |
Modifier and Type | Method and Description |
---|---|
int |
getPinCount()
Determine the current pin count.
|
boolean |
isPinned()
Determine the pin state of the memory.
|
void |
joinAndEnterPinned()
Same as
ScopedMemory.joinAndEnter()
except that the area may be pinned so the memory may not have been cleared. |
boolean |
joinAndEnterPinned(BooleanSupplier logic)
Same as
joinAndEnterPinned(Runnable) except that the
executed method is called get and a boolean is
returned. |
boolean |
joinAndEnterPinned(BooleanSupplier logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinned(Runnable, HighResolutionTime) except
that the executed method is called get and a boolean
is returned. |
double |
joinAndEnterPinned(DoubleSupplier logic)
Same as
joinAndEnterPinned(Runnable) except that the
executed method is called get and a double is returned. |
double |
joinAndEnterPinned(DoubleSupplier logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinned(Runnable, HighResolutionTime) except
that the executed method is called get and a double
is returned. |
void |
joinAndEnterPinned(HighResolutionTime<?> limit)
Same as
ScopedMemory.joinAndEnter(HighResolutionTime)
except that pinning is ignored so the memory may not have been cleared. |
int |
joinAndEnterPinned(IntSupplier logic)
Same as
joinAndEnterPinned(Runnable) except that the
executed method is called get and an int is returned. |
int |
joinAndEnterPinned(IntSupplier logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinned(Runnable, HighResolutionTime) except
that the executed method is called get and an int
is returned. |
long |
joinAndEnterPinned(LongSupplier logic)
Same as
joinAndEnterPinned(Runnable) except that the
executed method is called get and a long is returned. |
long |
joinAndEnterPinned(LongSupplier logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinned(Runnable, HighResolutionTime) except
that the executed method is called get and a long
is returned. |
void |
joinAndEnterPinned(Runnable logic)
Same as
ScopedMemory.joinAndEnter(Runnable) except that the
area may be pinned so the memory may not have been cleared. |
void |
joinAndEnterPinned(Runnable logic,
HighResolutionTime<?> limit)
Same as
ScopedMemory.joinAndEnter(Runnable, HighResolutionTime)
except that pinning is ignored so the memory may not have been cleared. |
<P> P |
joinAndEnterPinned(Supplier<P> logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinned(Runnable, HighResolutionTime) except
that the executed method is called get and an object
is returned. |
<T> T |
joinAndEnterPinned(Supplier<T> logic)
Same as
joinAndEnterPinned(Runnable) except that the
executed method is called get and an object is returned. |
double |
joinAndEnterPinnedInternal(DoubleSupplier logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinnedInternal(Runnable, HighResolutionTime)
except that the executed method is called get and a
double is returned. |
int |
joinAndEnterPinnedInternal(IntSupplier logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinnedInternal(Runnable, HighResolutionTime)
except that the executed method is called get and an int
is returned. |
long |
joinAndEnterPinnedInternal(LongSupplier logic,
HighResolutionTime<?> limit)
Same as
joinAndEnterPinnedInternal(Runnable, HighResolutionTime)
except that the executed method is called get and a long
is returned. |
void |
joinPinned()
Same as
ScopedMemory.join() except that the area may be
pinned so the memory may not have been cleared. |
void |
joinPinned(HighResolutionTime<?> limit)
Same as
ScopedMemory.join(HighResolutionTime) except that
the area may be pinned so the memory may not have been cleared. |
void |
pin()
Prevents the contents from being freed.
|
void |
unpin()
Allows the contents to be freed once no
Schedulable
is active within the scope. |
enter, enter, enter, enter, enter, enter, enter, executeInArea, executeInArea, executeInArea, executeInArea, executeInArea, executeInArea, getParent, getPortal, getReferenceCount, globalBackingStoreConsumed, globalBackingStoreRemaining, globalBackingStoreSize, join, join, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnter, joinAndEnterInternal, joinAndEnterInternal, joinAndEnterInternal, joinAndEnterInternal, joinAndEnterInternal, mayHoldReferenceTo, mayHoldReferenceTo, setPortal, toString
getMemoryArea, memoryConsumed, memoryRemaining, newArray, newArrayInArea, newInstance, newInstance, size
public PinnableMemory(long size)
Schedulable
has it on its scoped memory stack.StaticIllegalArgumentException
- when
size
is less than zero.StaticOutOfMemoryError
- when there is
insufficient memory for the PinnalbeMemory
object
or for its allocation area in its backing store, or when
the current Schedulable
would exceed its configured
allowance of global backing store.size
- The number of bytes in the memory area.public PinnableMemory(long size, Runnable logic)
Schedulable
has it on its scoped memory stack.StaticIllegalArgumentException
- when
size
is less than zero.StaticOutOfMemoryError
- when there is
insufficient memory for the PinnalbeMemory
object
or for its allocation area in its backing store, or when
the current Schedulable
would exceed its configured
allowance of global backing store.size
- The number of bytes in the memory area.logic
- The logic to execute when none is provide at enter.public PinnableMemory(SizeEstimator size)
PinnableMemory(long)
with
size.getEstimate()
as its argument.StaticIllegalArgumentException
- when
size
is null
.StaticOutOfMemoryError
- when there is
insufficient memory for the PinnalbeMemory
object
or for its allocation area in its backing store, or when
the current Schedulable
would exceed its configured
allowance of global backing store.size
- An estimator for determining the number of bytes in the
memory area.public PinnableMemory(SizeEstimator size, Runnable logic)
PinnableMemory(long, Runnable)
with
size.getEstimate()
as its first argument.StaticIllegalArgumentException
- when
size
is null
.StaticOutOfMemoryError
- when there is
insufficient memory for the PinnalbeMemory
object
or for its allocation area in its backing store, or when
the current Schedulable
would exceed its configured
allowance of global backing store.size
- An estimator for determining the number of bytes in the
memory area.logic
- The logic to execute when none is provide at enter.public void pin()
StaticIllegalStateException
- when the current allocation
context is not this
allocation context.public void unpin()
Schedulable
is active within the scope. The unpin
method must be
called as many times as pin()
to take effect. If there is
no task in the area when the call takes affect, then the object in
the area are reclaimed immediately, in the caller's context.StaticIllegalStateException
- when the current allocation
context is not this
allocation context.public boolean isPinned()
true
when the area is still pinned and
false
otherwise.public int getPinCount()
public void joinPinned(HighResolutionTime<?> limit) throws InterruptedException, StaticUnsupportedOperationException, StaticIllegalArgumentException
ScopedMemory.join(HighResolutionTime)
except that
the area may be pinned so the memory may not have been cleared.InterruptedException
- when this schedulable is
interrupted by RealtimeThread.interrupt()
or
javax.realtime.control.AsynchronouslyInterruptedException#fire()
while waiting for the reference count to go to zero.StaticUnsupportedOperationException
- when the
wait operation is not supported using the chronograph associated
with limit
.StaticIllegalArgumentException
limit
- The maximum time to wait.public void joinPinned() throws InterruptedException
ScopedMemory.join()
except that the area may be
pinned so the memory may not have been cleared.InterruptedException
- when this schedulable is
interrupted by RealtimeThread.interrupt()
or
javax.realtime.control.AsynchronouslyInterruptedException#fire()
while waiting for the reference count to go to zero.public void joinAndEnterPinned() throws InterruptedException, IllegalTaskStateException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
ScopedMemory.joinAndEnter()
except that the area may be pinned so the memory may not have been cleared.ScopedCycleException
- when the caller is a schedulable and
this invocation would break the single parent rule.InterruptedException
- when this schedulable is
interrupted by RealtimeThread.interrupt()
or
javax.realtime.control.AsynchronouslyInterruptedException#fire()
while waiting for the reference count to go to zero.IllegalTaskStateException
- 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 instance of Schedulable
that triggered finalization. This would include the scope
containing the instance of Schedulable
, and the
scope (if any) containing the scope containing the instance
of Schedulable
.MemoryAccessError
- when calling schedulable may not use the
heap and this memory area's logic value is allocated in
heap memory.StaticUnsupportedOperationException
public void joinAndEnterPinned(Runnable logic) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
ScopedMemory.joinAndEnter(Runnable)
except that the
area may be pinned so the memory may not have been cleared.ScopedCycleException
- when the caller is a schedulable and
this invocation would break the single parent rule.StaticIllegalArgumentException
- when logic
is
null
.InterruptedException
- when this schedulable is
interrupted by RealtimeThread.interrupt()
or
javax.realtime.control.AsynchronouslyInterruptedException#fire()
while waiting for the reference count to go to zero.IllegalTaskStateException
- 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 instance of Schedulable
that triggered finalization. This would include the scope
containing the instance of Schedulable
, and the
scope (if any) containing the scope containing the instance
of Schedulable
.MemoryAccessError
- when calling schedulable may not use the
heap and this memory area's logic
value is allocated in
heap memory.StaticUnsupportedOperationException
logic
- the code to be executed in this memory area.public <T> T joinAndEnterPinned(Supplier<T> logic) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable)
except that the
executed method is called get
and an object is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public boolean joinAndEnterPinned(BooleanSupplier logic) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable)
except that the
executed method is called get
and a boolean
is
returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public int joinAndEnterPinned(IntSupplier logic) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable)
except that the
executed method is called get
and an int
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public long joinAndEnterPinned(LongSupplier logic) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable)
except that the
executed method is called get
and a long
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public double joinAndEnterPinned(DoubleSupplier logic) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable)
except that the
executed method is called get
and a double
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public void joinAndEnterPinned(HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
ScopedMemory.joinAndEnter(HighResolutionTime)
except that pinning is ignored so the memory may not have been cleared.ScopedCycleException
- when the caller is a schedulable and
this invocation would break the single parent rule.InterruptedException
- when this schedulable is
interrupted by RealtimeThread.interrupt()
or
javax.realtime.control.AsynchronouslyInterruptedException#fire()
while waiting for the reference count to go to zero.IllegalTaskStateException
- 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.StaticIllegalArgumentException
- when the
caller is a schedulable, and limit
is null
or no non-null logic
value was supplied to the
memory area's constructor.MemoryAccessError
- when calling schedulable may not use the
heap and this memory area's logic
value is allocated in
heap memory.StaticUnsupportedOperationException
- when the
wait operation is not supported using the chronograph associated
with limit
.limit
- The maximum time to wait.public void joinAndEnterPinned(Runnable logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
ScopedMemory.joinAndEnter(Runnable, HighResolutionTime)
except that pinning is ignored so the memory may not have been cleared.InterruptedException
- when this schedulable is
interrupted by RealtimeThread.interrupt()
or
javax.realtime.control.AsynchronouslyInterruptedException#fire()
while waiting for the reference count to go to zero.ScopedCycleException
- when the caller is a schedulable and
this invocation would break the single parent rule.IllegalTaskStateException
- 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 instance of Schedulable
that triggered finalization. This would include the scope
containing the instance of Schedulable
, and the
scope (if any) containing the scope containing the instance
of Schedulable
.StaticIllegalArgumentException
- when the
calling schedulable and both logic
and the
logic value was supplied to the memory area's constructor
are null
.MemoryAccessError
- when calling schedulable may not use the
heap and this memory area's logic
value is allocated in
heap memory.StaticUnsupportedOperationException
- when the
wait operation is not supported using the chronograph associated
with limit
.logic
- The logic to execute upon entry.limit
- The maximum time to wait.public <P> P joinAndEnterPinned(Supplier<P> logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable, HighResolutionTime)
except
that the executed method is called get
and an object
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public boolean joinAndEnterPinned(BooleanSupplier logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable, HighResolutionTime)
except
that the executed method is called get
and a boolean
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public int joinAndEnterPinned(IntSupplier logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable, HighResolutionTime)
except
that the executed method is called get
and an int
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public long joinAndEnterPinned(LongSupplier logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable, HighResolutionTime)
except
that the executed method is called get
and a long
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public double joinAndEnterPinned(DoubleSupplier logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinned(Runnable, HighResolutionTime)
except
that the executed method is called get
and a double
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public int joinAndEnterPinnedInternal(IntSupplier logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinnedInternal(Runnable, HighResolutionTime)
except that the executed method is called get
and an int
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public long joinAndEnterPinnedInternal(LongSupplier logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinnedInternal(Runnable, HighResolutionTime)
except that the executed method is called get
and a long
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.public double joinAndEnterPinnedInternal(DoubleSupplier logic, HighResolutionTime<?> limit) throws InterruptedException, IllegalTaskStateException, StaticIllegalArgumentException, StaticUnsupportedOperationException, ScopedCycleException, MemoryAccessError
joinAndEnterPinnedInternal(Runnable, HighResolutionTime)
except that the executed method is called get
and a
double
is returned.InterruptedException
IllegalTaskStateException
StaticIllegalArgumentException
StaticUnsupportedOperationException
ScopedCycleException
MemoryAccessError
logic
- The object whose get method will be executed.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2022 aicas GmbH. All Rights Reserved.