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,
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.
|
Modifier and Type | Method and Description |
---|---|
void |
handleAsyncEvent()
handleAsyncEvent should be overwritten to contain the code to be
executed whenever this event is released.
|
void |
run()
run calls handleAsyncEvent repeatedly until the fire count
reaches zero.
|
addIfFeasible, addToFeasibility, finalize, getAndClearPendingFireCount, getAndDecrementPendingFireCount, getAndIncrementPendingFireCount, getDispatcher, getMemoryArea, getMemoryParameters, getPendingFireCount, getProcessingGroupParameters, getReleaseParameters, getScheduler, getSchedulingParameters, isDaemon, removeFromFeasibility, setDaemon, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setMemoryParameters, setMemoryParametersIfFeasible, setProcessingGroupParameters, setProcessingGroupParametersIfFeasible, setReleaseParameters, setReleaseParametersIfFeasible, setScheduler, setScheduler, setSchedulingParameters, setSchedulingParametersIfFeasible
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addIfFeasible, addToFeasibility, getMemoryParameters, getProcessingGroupParameters, getReleaseParameters, getScheduler, getSchedulingParameters, removeFromFeasibility, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setMemoryParameters, setMemoryParametersIfFeasible, setProcessingGroupParameters, setProcessingGroupParametersIfFeasible, setReleaseParameters, setReleaseParametersIfFeasible, setScheduler, setScheduler, setSchedulingParameters, setSchedulingParametersIfFeasible
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 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.
public final void run()
run
in interface Runnable
Thread.run()
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.