aicas logoJamaica 6.4 release 1

javax.realtime
Class AsyncEventHandler

java.lang.Object
  extended by javax.realtime.AbstractAsyncEventHandler
      extended by javax.realtime.AsyncEventHandler
All Implemented Interfaces:
Runnable, Schedulable
Direct Known Subclasses:
BoundAsyncEventHandler

public class AsyncEventHandler
extends AbstractAsyncEventHandler
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 Summary
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.
 
Method Summary
 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.
 
Methods inherited from class javax.realtime.AbstractAsyncEventHandler
addIfFeasible, addToFeasibility, finalize, getAndClearPendingFireCount, getAndDecrementPendingFireCount, getAndIncrementPendingFireCount, 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
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.realtime.Schedulable
addIfFeasible, addToFeasibility, getMemoryParameters, getProcessingGroupParameters, getReleaseParameters, getScheduler, getSchedulingParameters, removeFromFeasibility, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setMemoryParameters, setMemoryParametersIfFeasible, setProcessingGroupParameters, setProcessingGroupParametersIfFeasible, setReleaseParameters, setReleaseParametersIfFeasible, setScheduler, setScheduler, setSchedulingParameters, setSchedulingParametersIfFeasible
 

Constructor Detail

AsyncEventHandler

public AsyncEventHandler()
Constructor to create an instance of AsyncEventHandler with default parameters. This is short-hand for new AsyncEventHandler(null, null, null, null, null, false, null).


AsyncEventHandler

public AsyncEventHandler(Runnable logic)
Constructor to create an instance of AsyncEventHandler with default parameters and the specified value for the logic parameter. This is short-hand for new AsyncEventHandler(null, null, null, null, null, false, logic).

Parameters:
logic - the logic to executed or null.

AsyncEventHandler

public 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. This is short-hand for new AsyncEventHandler(scheduling, release, memory, area, group, false, logic).

Parameters:
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.

AsyncEventHandler

public AsyncEventHandler(boolean noheap)
Constructor to create an instance of AsyncEventHandler with default parameters and the specified value for the noheap parameter. This is short-hand for new AsyncEventHandler(null, null, null, null, null, noheap, null).

Parameters:
noheap - true to create an AsyncEventHandler that runs in a NoHeapRealtimeThread.

AsyncEventHandler

public 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. This is short-hand for new AsyncEventHandler(null, null, null, null, null, noheap, logic).

Parameters:
noheap - true to create an AsyncEventHandler that runs in a NoHeapRealtimeThread.
logic - the logic to executed or null.

AsyncEventHandler

public 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. This is short-hand for new AsyncEventHandler(scheduling, release, memory, area, group, noheap, null).

Parameters:
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.

AsyncEventHandler

public 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.

Parameters:
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.
Throws:
IllegalArgumentException - 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.
Method Detail

handleAsyncEvent

public void handleAsyncEvent()
handleAsyncEvent should be overwritten to contain the code to be executed whenever this event is released. The default implementation runs the logic given as an argument to the constructor. It performs no operation if no logic was provided.

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.


run

public final void run()
run calls handleAsyncEvent repeatedly until the fire count reaches zero. Subclasses cannot override this method, they should override handleAsyncEvent() instead.

Specified by:
run in interface Runnable
See Also:
Thread.run()

aicas logoJamaica 6.4 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2015 aicas GmbH. All Rights Reserved.