public abstract class AsyncBaseEventHandler extends Object implements Schedulable
An instance of this class contains code that will be released for execution when an asynchronous event occurs.
If an event occurs multiple times, the releases of one event handler will be serialized, i.e., one event handler will never be released more than once simultaneously. However, one event that is attached to several handlers can cause the simultaneous release of several event handlers.
If the release parameters associated with this handler are
SporadicParameters
, then the minimum interarrival time
specified in these parameters will be enforced.
The deadline specified is always relative to the fire time, even if
the actual release time may be later to enforce the minimum
interarrival time.
Handlers run in the context of a RealtimeThread
, they may run
for short or long times and they may block. Note that a handler that
is blocked may block all other handlers with the same scheduling
parameters since these handlers may share one instance of
RealtimeThread
. A handler may not call
RealtimeThread.waitForNextPeriod()
.
Several handlers share a common set of RealtimeThread
s for their
execution. This causes some additional overhead when releasing a
handler and it may cause a delayed execution if a handler with
equal scheduling parameters is blocked during execution. To avoid
these delays, handlers of type BoundSchedulable
may be used, these handlers are bound to their own RealtimeThread for
execution, but they require more system resources (threads and
memory).
A AsyncBaseEventHandler
may make use of memory areas just
as a RealtimeThread
does.
Modifier and Type | Method and Description |
---|---|
boolean |
addIfFeasible()
addIfFeasible adds this to the feasibility analysis of the
associated scheduler if the resulting system will be feasible.
|
boolean |
addToFeasibility()
addToFeasibility notifies the scheduler associated with this
that this schedulable object's scheduling, release, memory, and
processing group parameters take part in the feasibility
analysis.
|
protected void |
finalize()
finalizer to release and terminate execution thread that is not
needed any longer.
|
protected int |
getAndClearPendingFireCount()
Set the pending fire count to zero and returns the original value.
|
protected int |
getAndDecrementPendingFireCount()
Decrements the pending fire count and returns the original value.
|
TimeDispatcher |
getDispatcher()
Gets the dispatcher associated with this Timable.
|
MemoryArea |
getMemoryArea()
getMemoryArea returns the initial memory area provided to the
constructor of this handler.
|
MemoryParameters |
getMemoryParameters()
getMemoryParameters returns a reference to the MemoryParameters of
this
AsyncBaseEventHandler . |
protected int |
getPendingFireCount()
getPendingFireCount returns the current number of pending
invocations to handleAsyncEvent().
|
ProcessingGroupParameters |
getProcessingGroupParameters()
getProcessingGroupParameters returns the current
ProcessingGroupParameters of this
AsyncBaseEventHandler . |
ReleaseParameters<?> |
getReleaseParameters()
getReleaseParameters returns the current ReleaseParameters of this
AsyncBaseEventHandler . |
Scheduler |
getScheduler()
getScheduler returns the current scheduler of this handler.
|
SchedulingParameters |
getSchedulingParameters()
getSchedulingParameters returns the SchedulingParameters of this
handler.
|
boolean |
isDaemon()
Check if this is a daemon handler, i.e., one that does not keep the VM
from exiting.
|
boolean |
mayUseHeap()
Determines whether or not this
schedulable may use the heap. |
boolean |
removeFromFeasibility()
removeFromFeasibility informs the scheduler associated with this
AsyncBaseEventHandler that this
AsyncBaseEventHandler should no longer be taken into account
in the feasibility analysis. |
void |
run()
Calls
handleAsyncEvent repeatedly until the fire count
reaches zero. |
void |
setDaemon(boolean on)
Mark this handler as daemon or non-daemon.
|
boolean |
setIfFeasible(ReleaseParameters<?> release,
MemoryParameters memory)
setIfFeasible performs a feasibility analysis using the provided
release and memory parameters.
|
boolean |
setIfFeasible(ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters group)
setIfFeasible performs a feasibility analysis using the provided
release, memory, and processing group parameters.
|
boolean |
setIfFeasible(ReleaseParameters<?> release,
ProcessingGroupParameters group)
setIfFeasible performs a feasibility analysis using the provided
release and processing group parameters.
|
boolean |
setIfFeasible(SchedulingParameters sched,
ReleaseParameters<?> release,
MemoryParameters memory)
setIfFeasible performs a feasibility analysis using the provided
scheduling, release and memory parameters.
|
boolean |
setIfFeasible(SchedulingParameters sched,
ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters group)
setIfFeasible performs a feasibility analysis using the provided
scheduling, release, memory, and processing group parameters.
|
Schedulable |
setMemoryParameters(MemoryParameters memory)
setMemoryParameters replaces the memory parameters for this
handler with the parameters provided.
|
boolean |
setMemoryParametersIfFeasible(MemoryParameters memory)
setMemoryParametersIfFeasible performs a feasibility analysis
using the provided memory parameters.
|
void |
setProcessingGroupParameters(ProcessingGroupParameters group)
setProcessingGroupParameters sets the processing group parameters
of this handler.
|
boolean |
setProcessingGroupParametersIfFeasible(ProcessingGroupParameters group)
setProcessingGroupParametersIfFeasible performs a feasibility
analysis using the provided processing group parameters.
|
Schedulable |
setReleaseParameters(ReleaseParameters<?> release)
setReleaseParameters replaces the release parameters for this
handler with the parameters provided.
|
boolean |
setReleaseParametersIfFeasible(ReleaseParameters<?> release)
setReleaseParametersIfFeasible performs a feasibility analysis
using the provided release parameters.
|
Schedulable |
setScheduler(Scheduler scheduler)
setScheduler sets the scheduler for this handler.
|
void |
setScheduler(Scheduler scheduler,
SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters group)
setScheduler sets the scheduler and scheduling, release,
memory, and processing group parameters for this handler.
|
Schedulable |
setSchedulingParameters(SchedulingParameters scheduling)
setSchedulingParameters sets the scheduling parameters for this
Schedulable.
|
boolean |
setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
setSchedulingParametersIfFeasible performs a feasibility
analysis using the provided scheduling parameters.
|
boolean |
subsumes(Schedulable other)
Determine whether or not this instance of
Schedulable is
more eligible than other . |
protected int getPendingFireCount()
protected int getAndClearPendingFireCount()
handleAsyncEvent
.protected int getAndDecrementPendingFireCount()
handleAsyncEvent
.public final boolean isDaemon()
isDaemon
in interface Schedulable
public boolean mayUseHeap()
schedulable
may use the heap.mayUseHeap
in interface Schedulable
true
only when this Schedulable
may allocate
on the heap and may enter the Heap
.public final void setDaemon(boolean on)
Mark this handler as daemon or non-daemon. Non-Daemon event handlers prevent the VM from exiting as long as they run. This must be called before this handler is attached to an event, the state cannot be changed later.
By default, all newly created handlers are daemon handler unless they are turned into non-daemon handlers explicitly by a call to setDaemon(false).
setDaemon
in interface Schedulable
IllegalTaskStateException
- if this handler is attached
to an async event.SecurityException
- if this change is not allowed for the
current schedulable object.on
- true to select daemon state, false for non-daemon
state.public MemoryArea getMemoryArea()
public boolean addToFeasibility()
addToFeasibility notifies the scheduler associated with this that this schedulable object's scheduling, release, memory, and processing group parameters take part in the feasibility analysis.
In case this schedulable object is already part of the feasibility analysis, do nothing.
addToFeasibility
in interface Schedulable
public boolean addIfFeasible()
addIfFeasible adds this to the feasibility analysis of the associated scheduler if the resulting system will be feasible.
If the object is already included in the feasible set, do nothing.
addIfFeasible
in interface Schedulable
public boolean setIfFeasible(ReleaseParameters<?> release, MemoryParameters memory) throws StaticIllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
setIfFeasible performs a feasibility analysis using the provided release and memory parameters. If the system remains feasible with these new parameters, the parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this AsyncBaseEventHandler
.IllegalAssignmentError
- if release or memory and this
reside in memory areas whose objects cannot refer to one another
(in both directions).IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic, and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.public boolean setIfFeasible(SchedulingParameters sched, ReleaseParameters<?> release, MemoryParameters memory) throws StaticIllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
setIfFeasible performs a feasibility analysis using the provided scheduling, release and memory parameters. If the system remains feasible with these new parameters, the scheduling, release, and memory parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this AsyncBaseEventHandler
.IllegalAssignmentError
- if sched, release or memory and
this reside in memory areas whose objects cannot refer to one
another (in both directions).IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic, and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.sched
- the new scheduling parameters. If null, the default
value of the associated scheduler will be used. This
default value may be null.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.public boolean setIfFeasible(ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters group) throws StaticIllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
setIfFeasible performs a feasibility analysis using the provided release, memory, and processing group parameters. If the system remains feasible with these new parameters, the parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- if release, memory or group and
this reside in memory areas whose objects cannot refer to one
another (in both directions).IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic, and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.group
- the new processing group parameters. If null, the
default value for the associated scheduler will be used.public boolean setIfFeasible(SchedulingParameters sched, ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters group) throws StaticIllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
setIfFeasible performs a feasibility analysis using the provided scheduling, release, memory, and processing group parameters. If the system remains feasible with these new parameters, the scheduling, release, memory, and processing group parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this AsyncBaseEventHandler
.IllegalAssignmentError
- if sched, release, memory or group
and this reside in memory areas whose objects cannot refer to one
another (in both directions).IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic, and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.sched
- the new scheduling parameters. If null, the default
value of the associated scheduler will be used. This
default value may be null.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.group
- the new processing group parameters. If null, the
default value for the associated scheduler will be used.public boolean setReleaseParametersIfFeasible(ReleaseParameters<?> release) throws IllegalThreadStateException
setReleaseParametersIfFeasible performs a feasibility analysis using the provided release parameters. If the system remains feasible with the new parameters, the parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setReleaseParametersIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- if release and this reside in
memory areas whose objects cannot refer to one another (in both
directions).IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic, and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.public boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters group)
setProcessingGroupParametersIfFeasible performs a feasibility analysis using the provided processing group parameters. If the system remains feasible with these new parameters, parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setProcessingGroupParametersIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the group parameter value is
not compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- If group and this reside in memory
areas whose objects cannot refer to one another (in both
directions).group
- the new processing group parameters. If null, the
default value for the associated scheduler will be used.public boolean setIfFeasible(ReleaseParameters<?> release, ProcessingGroupParameters group) throws StaticIllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
setIfFeasible performs a feasibility analysis using the provided release and processing group parameters. If the system remains feasible with these new parameters, the parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- if release or group and this
reside in memory areas whose objects cannot refer to one another
(in both directions).IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic, and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.group
- the new processing group parameters. If null, the
default value for the associated scheduler will be used.public boolean setMemoryParametersIfFeasible(MemoryParameters memory)
setMemoryParametersIfFeasible performs a feasibility analysis using the provided memory parameters. If the system remains feasible with the new memory parameters, the parameters are replaced.
In JamaicaVM, this change becomes effective immediately.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setMemoryParametersIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the memory parameter value is
not compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- if memory and this reside in
memory areas whose objects cannot refer to one another (in both
directions).memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.public MemoryParameters getMemoryParameters()
AsyncBaseEventHandler
.getMemoryParameters
in interface Schedulable
AsyncBaseEventHandler
.public ReleaseParameters<?> getReleaseParameters()
AsyncBaseEventHandler
.getReleaseParameters
in interface Schedulable
public Scheduler getScheduler()
getScheduler
in interface Schedulable
public SchedulingParameters getSchedulingParameters()
getSchedulingParameters
in interface Schedulable
public ProcessingGroupParameters getProcessingGroupParameters()
AsyncBaseEventHandler
.getProcessingGroupParameters
in interface Schedulable
public boolean removeFromFeasibility()
AsyncBaseEventHandler
that this
AsyncBaseEventHandler
should no longer be taken into account
in the feasibility analysis.removeFromFeasibility
in interface Schedulable
public Schedulable setMemoryParameters(MemoryParameters memory) throws IllegalThreadStateException
This change may change the feasibility of the current feasible set of this handler's scheduler.
In JamaicaVM, this change becomes effective at the next release of the handler.
setMemoryParameters
in interface Schedulable
StaticIllegalArgumentException
- if the memory parameter value is
not compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- if memory and this reside in
memory areas whose objects cannot refer to one another (in both
directions).IllegalThreadStateException
memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.public Schedulable setReleaseParameters(ReleaseParameters<?> release) throws IllegalThreadStateException
setReleaseParameters replaces the release parameters for this handler with the parameters provided.
This change may change the feasibility of the current feasible set of this handler's scheduler.
setReleaseParameters
in interface Schedulable
StaticIllegalArgumentException
- if the release parameter value
is not compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- if release and this reside in
memory areas whose objects cannot refer to one another (in both
directions).IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic, and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.public void setScheduler(Scheduler scheduler, SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters group) throws StaticIllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException, SecurityException
setScheduler sets the scheduler and scheduling, release, memory, and processing group parameters for this handler.
The change of the scheduler and the scheduling and memory parameters will be immediate for the default scheduler. release, and processing group parameters will take effect on the next release.
This change may change the feasibility of the current feasible set of this handler's scheduler.
setScheduler
in interface Schedulable
StaticIllegalArgumentException
- if scheduler is null or the
scheduling, release, memory, or processing group parameters are
not compatible with the scheduler.IllegalAssignmentError
- if scheduler, scheduling, release,
memory, or group reside in memory areas whose objects cannot be
referred to by this or this object resides in a memory area that
cannot be referenced by scheduling, release, or memory.IllegalThreadStateException
- If the old release parameters
are periodic, the new release parameters are not periodic and the
schedulable object is currently blocked in waitForNextPeriod or
waitForNextPeriodInterruptible.SecurityException
- if setting of the scheduler is not
allowed by the current RealtimeSystem setting.scheduler
- The scheduler to be used for this handler. Must
not be null.scheduling
- SchedulingParameters to be associated with the
handler. If null, the default value of the scheduler will
be used.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.group
- the new processing group parameters to be applied
for the next release of this. If null, the default value for
the scheduler will be used.public Schedulable setScheduler(Scheduler scheduler) throws StaticIllegalArgumentException, IllegalAssignmentError, SecurityException
setScheduler sets the scheduler for this handler. If this has been admitted to the feasible set, it remains in the feasible set.
This change may change the feasibility of the current feasible set of this handler's scheduler.
setScheduler
in interface Schedulable
StaticIllegalArgumentException
- iff the scheduler is null or the
current parameters of this are not compatible with the new
scheduler.IllegalAssignmentError
- if scheduler and this reside in
memory areas whose objects cannot refer to one another (in both
directions).SecurityException
- if setting of the scheduler is not
allowed by the current RealtimeSystem setting.scheduler
- the new scheduler to be used. Must not be null.public Schedulable setSchedulingParameters(SchedulingParameters scheduling) throws IllegalThreadStateException
Schedulable
setSchedulingParameters sets the scheduling parameters for this Schedulable.
In JamaicaVM, this change of scheduling parameters becomes effective immediately for the default PriorityScheduler.
setSchedulingParameters
in interface Schedulable
IllegalThreadStateException
scheduling
- the new scheduling parameters.public void setProcessingGroupParameters(ProcessingGroupParameters group)
setProcessingGroupParameters sets the processing group parameters of this handler.
In JamaicaVM, this change becomes effective immediately.
This change may change the feasibility of the current feasible
set of this AsyncBaseEventHandler
's scheduler.
setProcessingGroupParameters
in interface Schedulable
StaticIllegalArgumentException
- if the group argument is not
compatible with the scheduler of this RealtimeThread.group
- the new processing group parameters to be applied
for the next release of this. If null, use the default value for
the scheduler.public boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
setSchedulingParametersIfFeasible performs a feasibility analysis using the provided scheduling parameters. If the system remains feasible with these new parameters, the scheduling parameters are replaced.
In JamaicaVM, this change of the scheduling parameters becomes effective immediately for the default PriorityScheduler.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
setSchedulingParametersIfFeasible
in interface Schedulable
StaticIllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this
AsyncBaseEventHandler
.IllegalAssignmentError
- if sched, release, memory or group
and this reside in memory areas whose objects cannot refer to one
another (in both directions).scheduling
- the new scheduling parameters. If null, the
default value of the associated scheduler will be
used. This default value may be null.protected void finalize() throws Throwable
finalize
in class Object
Throwable
- the Exception
raised by this methodWeakReference
,
PhantomReference
public TimeDispatcher getDispatcher()
getDispatcher
in interface Releasable<Timable,TimeDispatcher>
getDispatcher
in interface Timable
UnsupportedOperationException
- always, since it is not yet
implemented.public boolean subsumes(Schedulable other)
Schedulable
Schedulable
is
more eligible than other
. On multicore systems, this only
gives a partial ordering over all schedulables. Schedulables with
disjoint processor affinity do not subsume one another.subsumes
in interface Schedulable
subsumes
in interface Subsumable<Schedulable>
other
- The object to be compared with.true
when and only when this instance of
Schedulable
is more eligible than other
.public final void run()
handleAsyncEvent
repeatedly until the fire count
reaches zero. The method is only to be used by the infrastructure,
and should not be called by the application. The handleAsyncEvent
method should be overridden instead.
The handleAsyncEvent()
family of methods provides the
equivalent functionality to Runnable.run()
for asynchronous
event handlers, including execution of the logic
argument
passed to this object's constructor. Applications should override
the handleAsyncEvent()
method instead of overwriting this method.
run
in interface Runnable
Thread.run()
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2022 aicas GmbH. All Rights Reserved.