public class AsyncEventHandler extends AsyncBaseEventHandler implements Schedulable
Jamaica Real-Time Specification for Java class AsyncEventHandler.
An instance of this class contains code that will be released for execution when an asynchronous event (AsyncEvent) 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 RealtimeThreads 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 class BoundAsyncEventHandler
may be used,
these handlers are bound to their own RealtimeThread for execution,
but they require more system resources (threads and
memory).
AsyncEventHandlers may make use of memory areas exactly as RealtimeThreads do.
Constructor and Description |
---|
AsyncEventHandler()
Constructor to create an instance of AsyncEventHandler with
default parameters.
|
AsyncEventHandler(boolean noheap)
Constructor to create an instance of AsyncEventHandler with
default parameters and the specified value for the noheap
parameter.
|
AsyncEventHandler(boolean noheap,
Runnable logic)
Constructor to create an instance of AsyncEventHandler with
default parameters and the specified values for the noheap and
logic parameters.
|
AsyncEventHandler(Runnable logic)
Constructor to create an instance of AsyncEventHandler with
default parameters and the specified value for the logic
parameter.
|
AsyncEventHandler(SchedulingParameters scheduling,
ReleaseParameters<?> release) |
AsyncEventHandler(SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
MemoryArea area,
ProcessingGroupParameters group,
boolean noheap)
Constructor to create an instance of AsyncEventHandler with the given
scheduling, release, memory, memory area, processing group, and
noheap parameters.
|
AsyncEventHandler(SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
MemoryArea area,
ProcessingGroupParameters group,
boolean noheap,
Runnable logic)
Constructor to create an instance of AsyncEventHandler with the given
scheduling, release, memory, memory area, processing group,
noheap, and logic parameters.
|
AsyncEventHandler(SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
MemoryArea area,
ProcessingGroupParameters group,
Runnable logic)
Constructor to create an instance of AsyncEventHandler with the given
scheduling, release, memory, memory area, processing group, and
logic parameters.
|
AsyncEventHandler(SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
MemoryArea area,
ReleaseRunner runner,
Runnable logic) |
AsyncEventHandler(SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
MemoryArea area,
Runnable logic) |
AsyncEventHandler(SchedulingParameters scheduling,
ReleaseParameters<?> release,
Runnable logic) |
Modifier and Type | Method and Description |
---|---|
protected int |
getAndIncrementPendingFireCount()
This is an accessor method for
fireCount_ . |
void |
handleAsyncEvent()
handleAsyncEvent should be overwritten to contain the code to be
executed whenever this event is released.
|
addIfFeasible, addToFeasibility, finalize, getAndClearPendingFireCount, getAndDecrementPendingFireCount, getDispatcher, getMemoryArea, getMemoryParameters, getPendingFireCount, getProcessingGroupParameters, getReleaseParameters, getScheduler, getSchedulingParameters, isDaemon, mayUseHeap, removeFromFeasibility, run, setDaemon, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setMemoryParameters, setMemoryParametersIfFeasible, setProcessingGroupParameters, setProcessingGroupParametersIfFeasible, setReleaseParameters, setReleaseParametersIfFeasible, setScheduler, setScheduler, setSchedulingParameters, setSchedulingParametersIfFeasible, subsumes
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addIfFeasible, addToFeasibility, getMemoryParameters, getProcessingGroupParameters, getReleaseParameters, getScheduler, getSchedulingParameters, isDaemon, mayUseHeap, removeFromFeasibility, setDaemon, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setMemoryParameters, setMemoryParametersIfFeasible, setProcessingGroupParameters, setProcessingGroupParametersIfFeasible, setReleaseParameters, setReleaseParametersIfFeasible, setScheduler, setScheduler, setSchedulingParameters, setSchedulingParametersIfFeasible, subsumes
getDispatcher
public AsyncEventHandler()
public AsyncEventHandler(Runnable logic)
logic
- the logic to executed or null.public AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, Runnable logic)
scheduling
- SchedulingParameters to be associated with the new
async event handler. This can be shared with several Schedulable
objects. If it is null, a copy of the creator's value will be
created in the same memory area as this AEH object. If it is null
and the current thread is a normal Java thread, the scheduling
parameters will be set to the default priority.release
- ReleaseParameters to be associated with the new async
event handler. This can be shared with several Schedulable
objects. If it is null, default release parameters will be used.memory
- MemoryParameters to be associated with the new
thread. May be null for unrestricted amount and rate of memory
allocation for the new AEH.area
- MemoryArea to be used by the new AEH. If it is null,
the current memory area of the calling thread will be used.group
- ProcessingGroupParameters to be associated with
this. This can be shared with several Schedulable objects. If it
is null, this will not be associated with any processing group.public AsyncEventHandler(boolean noheap)
noheap
- true to create an AsyncEventHandler that runs in a
NoHeapRealtimeThread.public AsyncEventHandler(boolean noheap, Runnable logic)
noheap
- true to create an AsyncEventHandler that runs in a
NoHeapRealtimeThread.logic
- the logic to executed or null.public AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, boolean noheap)
scheduling
- SchedulingParameters to be associated with the new
async event handler. This can be shared with several Schedulable
objects. If it is null, a copy of the creator's value will be
created in the same memory area as this AEH object. If it is null
and the current thread is a normal Java thread, the scheduling
parameters will be set to the default priority.release
- ReleaseParameters to be associated with the new
AsyncEventHandler. This can be shared with several Schedulable
objects. If it is null, default release parameters will be used.memory
- MemoryParameters to be associated with new
thread. May be null for unrestricted amount and rate of memory
allocation for the new AEH.area
- MemoryArea to be used by the new AEH. If it is null,
the current memory area of the calling thread will be used.group
- ProcessingGroupParameters to be associated with
this. This can be shared with several Schedulable objects. If it
is null, this will not be associated with any processing group.noheap
- true to create an AsyncEventHandler that runs in a
NoHeapRealtimeThread.public AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, boolean noheap, Runnable logic)
StaticIllegalArgumentException
- iff scheduling or release
parameters are not compatible with the default scheduler, i.e.,
iff they are non-null and not an instance of PriorityParameters
or PeriodicParameters, AperiodicParameters and
SporadicParameters, respectively.IllegalAssignmentError
- if scheduling, release, memory,
area, group, or logic 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.scheduling
- SchedulingParameters to be associated with the new
AsyncEventHandler. This can be shared with several Schedulable
objects. If it is null, a copy of the creator's value will be
created in the same memory area as this AEH object. If it is null
and the current thread is a normal Java thread, the scheduling
parameters will be set to the default priority.release
- ReleaseParameters to be associated with the new
AsyncEventHandler. This can be shared with several Schedulable
objects. If it is null, default release parameters will be used.memory
- MemoryParameters to be associated with the new
thread. May be null for unrestricted amount and rate of memory
allocation for the new AEH.area
- MemoryArea to be used by the new AEH. If it is null,
the current memory area of the calling thread will be used.group
- ProcessingGroupParameters to be associated with
this. This can be shared with several Schedulable objects. If it
is null, this will not be associated with any processing group.noheap
- true to create an AsyncEventHandler that runs in a
NoHeapRealtimeThread.logic
- Runnable to be used as the logic for this. If is is
null, the run() method in this new AsyncEventHandler object will be
called when the thread is started.public AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters<?> release)
public AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters<?> release, Runnable logic)
public AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, MemoryArea area, Runnable logic)
public AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, MemoryArea area, ReleaseRunner runner, Runnable logic)
public void handleAsyncEvent()
This method will be called repeatedly while fireCount_ is greater than zero, the fireCount_ will be reduced by one after each call.
Any throwable thrown by this method will be caught, the stack trace will be printed and the exception will be ignored.
protected int getAndIncrementPendingFireCount() throws MITViolationException, ArrivalTimeQueueOverflowException
fireCount_
.
This method atomically increments, by one, the value of
fireCount_
and returns the value from before the
increment.
Calling this method is effectively the same as firing an event that is associated with this handler. When called from outside the handler's control flow, call it is effectively the same as firing an event that is associated with this handler, except that it does not constitute a release event.
MITViolationException
- when this AEH is controlled by
sporadic scheduling parameters under the base scheduler,
the parameters specify the mitViolationExcept
policy, and this method would introduce a release that
would violate the specified minimum interarrival time.ArrivalTimeQueueOverflowException
- when this AEH is
controlled by aperiodic scheduling parameters under the
base scheduler, the release parameters specify the
arrivalTimeQueueOverflowExcept
policy, and
this method would cause the arrival time queue to overflow.fireCount_
prior to
incrementing it by one.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2021 aicas GmbH. All Rights Reserved.