javax.realtime
Class AsyncEventHandler

java.lang.Object
  extended byjavax.realtime.AsyncEventHandler
All Implemented Interfaces:
Runnable, Schedulable
Direct Known Subclasses:
BoundAsyncEventHandler, PooledAsyncEventHandler

public class AsyncEventHandler
extends Object
implements Schedulable

An asynchronous event handler encapsulates code that gets run at some time after an AsyncEvent occurs. It is essentially a java.lang.Runnable with a set of parameter objects, making it very much like a RealtimeThread . The expectation is that there may be thousands of events, with corresponding handlers, averaging about one handler per event. The number of unblocked (i.e., scheduled) handlers is expected to be relatively small.
It is guaranteed that multiple firings of an event handler will be serialized. It is also guaranteed that (unless the handler explicitly chooses otherwise) for each firing of the handler, there will be one execution of the handleAsyncEvent() method. For instances of AsyncEventHandler with a release parameter of type SporadicParameters have a list of release times which correspond to execution times of AsyncEvent.fire() . The minimum interarrival time specified in SporadicParameters is enforced as defined there. Unless the handler explicitly chooses otherwise there will be one execution of the code in handleAsyncEvent() for each entry in the list. The i th execution of handleAsyncEvent() will be released for scheduling at the time of the i th entry in thelist. There is no restriction on what handlers may do. They may run for a long or short time, and they may block. (Note: blocked handlers may hold system resources.) Normally, handlers are bound to an execution context dynamically, when their AsyncEvent181 occurs. This can introduce a (small) time penalty. For critical handlers that can not afford the expense, and where this penalty is a problem, use a BoundAsyncEventHandler. The semantics for memory areas that were defined for realtime threads apply in the same way to instances of AsyncEventHandler They may inherit a scope stack when they are created, and the single parent rule applies to the use of memory scopes for instances of AsyncEventHandler just as it does in realtime threads.

Author:
Angelo Corsaro, Morgan Deters

Constructor Summary
AsyncEventHandler()
           
AsyncEventHandler(boolean nonheap)
           
AsyncEventHandler(boolean nonheap, Runnable logic)
           
AsyncEventHandler(Runnable logic)
           
AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, boolean nonheap)
           
AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, boolean nonheap, Runnable logic)
           
AsyncEventHandler(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, Runnable logic)
           
 
Method Summary
 boolean addIfFeasible()
          Add to the feasibility of the associated scheduler if the resulting feasibility is Schedulable.
 boolean addToFeasibility()
          Inform the scheduler and cooperating facilities that the resource demands (as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters, and ProcessingGroupParameters) of this instance of Schedulable will be considered in the feasibility analysis of the associated Scheduler until further notice.
 int executionEligibility()
           
protected  void finalize()
           
 MemoryArea getMemoryArea()
           
 MemoryParameters getMemoryParameters()
          Get the MemoryParameters of this Schedulable object.
 ProcessingGroupParameters getProcessingGroupParameters()
          Get the ProcessingGroupParameters of this Schedulable object.
 ReleaseParameters getReleaseParameters()
          Get the ReleaseParameters of this Schedulable object.
 Scheduler getScheduler()
          Get the Scheduler for this Schedulable object.
 SchedulingParameters getSchedulingParameters()
          Get the SchedulingParameters for this Schedulable object.
 void handleAsyncEvent()
          If this handler was constructed using a separate Runnable logic object, then that Runnable objects run method is called; This method will be invoked repeatedly while fireCount is greater than zero.
 boolean removeFromFeasibility()
          Inform the scheduler and cooperating facilities that the resource demands, as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters, and ProcessingGroupParameters, of this instance of Schedulable should no longer be considered in the feasibility analysis of the associated Scheduler.
 void run()
          Used by the asynchronous event mechanism, see AsyncEvent.
 void setDaemon(boolean on)
           
 boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory)
           
 boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
           
 boolean setIfFeasible(ReleaseParameters release, ProcessingGroupParameters group)
           
 boolean setIfFeasible(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory)
           
 boolean setIfFeasible(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
           
 void setMemoryParameters(MemoryParameters memory)
          Set the MemoryParameters for this Schedulable object.
 boolean setMemoryParametersIfFeasible(MemoryParameters memory)
          Set the MemoryParameters for this Schedulable object.
 void setProcessingGroupParameters(ProcessingGroupParameters group)
          Set the ProcessingGroupParameters for this Schedulable object.
 boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters group)
          Set the ProcessingGroupParameters of this Schedulable object only if the resulting task set is feasible.
 void setReleaseParameters(ReleaseParameters release)
          Set the ReleaseParameters for this Schedulable object.
 boolean setReleaseParametersIfFeasible(ReleaseParameters release)
          Set the ReleaseParameters for this Schedulable object only if the resulting task set is feasible.
 void setScheduler(Scheduler scheduler)
          Set the Scheduler for this Schedulable object.
 void setScheduler(Scheduler scheduler, SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
          Set the Scheduler for this Schedulable object.
 void setSchedulingParameters(SchedulingParameters scheduling)
          Set the SchedulingParameters for this Schedulable object only if the resulting task set is feasible.
 boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
          Set the SchedulingParameters for this Schedulable object.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncEventHandler

public AsyncEventHandler()

AsyncEventHandler

public AsyncEventHandler(boolean nonheap)

AsyncEventHandler

public AsyncEventHandler(boolean nonheap,
                         Runnable logic)

AsyncEventHandler

public AsyncEventHandler(Runnable logic)

AsyncEventHandler

public AsyncEventHandler(SchedulingParameters scheduling,
                         ReleaseParameters release,
                         MemoryParameters memory,
                         MemoryArea area,
                         ProcessingGroupParameters group,
                         boolean nonheap)

AsyncEventHandler

public AsyncEventHandler(SchedulingParameters scheduling,
                         ReleaseParameters release,
                         MemoryParameters memory,
                         MemoryArea area,
                         ProcessingGroupParameters group,
                         Runnable logic)

AsyncEventHandler

public AsyncEventHandler(SchedulingParameters scheduling,
                         ReleaseParameters release,
                         MemoryParameters memory,
                         MemoryArea area,
                         ProcessingGroupParameters group,
                         boolean nonheap,
                         Runnable logic)
Method Detail

handleAsyncEvent

public void handleAsyncEvent()
If this handler was constructed using a separate Runnable logic object, then that Runnable objects run method is called; This method will be invoked repeatedly while fireCount is greater than zero.


getMemoryArea

public MemoryArea getMemoryArea()

addToFeasibility

public boolean addToFeasibility()
Description copied from interface: Schedulable
Inform the scheduler and cooperating facilities that the resource demands (as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters, and ProcessingGroupParameters) of this instance of Schedulable will be considered in the feasibility analysis of the associated Scheduler until further notice. Whether the resulting system is feasible or not, the addition is completed.

Specified by:
addToFeasibility in interface Schedulable
Returns:
true if the resulting system is feasible

addIfFeasible

public boolean addIfFeasible()
Description copied from interface: Schedulable
Add to the feasibility of the associated scheduler if the resulting feasibility is Schedulable. If successful return true, if not return false. If there is not assigned scheduler false is returned.

Specified by:
addIfFeasible in interface Schedulable
Returns:
true if the resulting scheduler is feasible.

setIfFeasible

public boolean setIfFeasible(ReleaseParameters release,
                             MemoryParameters memory)
Specified by:
setIfFeasible in interface Schedulable

setIfFeasible

public boolean setIfFeasible(ReleaseParameters release,
                             MemoryParameters memory,
                             ProcessingGroupParameters group)
Specified by:
setIfFeasible in interface Schedulable

setIfFeasible

public boolean setIfFeasible(ReleaseParameters release,
                             ProcessingGroupParameters group)
Specified by:
setIfFeasible in interface Schedulable

setIfFeasible

public boolean setIfFeasible(SchedulingParameters scheduling,
                             ReleaseParameters release,
                             MemoryParameters memory)
Specified by:
setIfFeasible in interface Schedulable

setIfFeasible

public boolean setIfFeasible(SchedulingParameters scheduling,
                             ReleaseParameters release,
                             MemoryParameters memory,
                             ProcessingGroupParameters group)
Specified by:
setIfFeasible in interface Schedulable

setReleaseParametersIfFeasible

public boolean setReleaseParametersIfFeasible(ReleaseParameters release)
Description copied from interface: Schedulable
Set the ReleaseParameters for this Schedulable object only if the resulting task set is feasible.

Specified by:
setReleaseParametersIfFeasible in interface Schedulable
Parameters:
release - a ReleaseParameters value

setProcessingGroupParametersIfFeasible

public boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters group)
Description copied from interface: Schedulable
Set the ProcessingGroupParameters of this Schedulable object only if the resulting task set is feasible.

Specified by:
setProcessingGroupParametersIfFeasible in interface Schedulable
Parameters:
group - a ProcessingGroupParameters value
Returns:
true if, after considering the values of the parameters, the task set would still be feasible. In this case the values of the parameters are changed; false if, after considering the values of the parameters, the task set would not be feasible (in which case the values of the parameters are not changed)

setMemoryParametersIfFeasible

public boolean setMemoryParametersIfFeasible(MemoryParameters memory)
Description copied from interface: Schedulable
Set the MemoryParameters for this Schedulable object.

Specified by:
setMemoryParametersIfFeasible in interface Schedulable
Parameters:
memory - the MemoryParameters for this Schedulable object
Returns:
true if the requested change keeps the system feasible

getMemoryParameters

public MemoryParameters getMemoryParameters()
Description copied from interface: Schedulable
Get the MemoryParameters of this Schedulable object.

Specified by:
getMemoryParameters in interface Schedulable
Returns:
a MemoryParameters value

getReleaseParameters

public ReleaseParameters getReleaseParameters()
Description copied from interface: Schedulable
Get the ReleaseParameters of this Schedulable object.

Specified by:
getReleaseParameters in interface Schedulable
Returns:
a ReleaseParameters value

getScheduler

public Scheduler getScheduler()
Description copied from interface: Schedulable
Get the Scheduler for this Schedulable object.

Specified by:
getScheduler in interface Schedulable
Returns:
a Scheduler value

getSchedulingParameters

public SchedulingParameters getSchedulingParameters()
Description copied from interface: Schedulable
Get the SchedulingParameters for this Schedulable object.

Specified by:
getSchedulingParameters in interface Schedulable
Returns:
a SchedulingParameters value

getProcessingGroupParameters

public ProcessingGroupParameters getProcessingGroupParameters()
Description copied from interface: Schedulable
Get the ProcessingGroupParameters of this Schedulable object.

Specified by:
getProcessingGroupParameters in interface Schedulable
Returns:
a ProcessingGroupParameters value

removeFromFeasibility

public boolean removeFromFeasibility()
Description copied from interface: Schedulable
Inform the scheduler and cooperating facilities that the resource demands, as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters, and ProcessingGroupParameters, of this instance of Schedulable should no longer be considered in the feasibility analysis of the associated Scheduler. Whether the resulting system is feasible or not, the subtrac-tion is completed.

Specified by:
removeFromFeasibility in interface Schedulable
Returns:
true If the resulting system is feasible.

setMemoryParameters

public void setMemoryParameters(MemoryParameters memory)
Description copied from interface: Schedulable
Set the MemoryParameters for this Schedulable object.

Specified by:
setMemoryParameters in interface Schedulable
Parameters:
memory - the MemoryParameters for this Schedulable object

setReleaseParameters

public void setReleaseParameters(ReleaseParameters release)
Description copied from interface: Schedulable
Set the ReleaseParameters for this Schedulable object.

Specified by:
setReleaseParameters in interface Schedulable
Parameters:
release - a ReleaseParameters value

setScheduler

public void setScheduler(Scheduler scheduler)
Description copied from interface: Schedulable
Set the Scheduler for this Schedulable object.

Specified by:
setScheduler in interface Schedulable
Parameters:
scheduler - the scheduler.

setScheduler

public void setScheduler(Scheduler scheduler,
                         SchedulingParameters scheduling,
                         ReleaseParameters release,
                         MemoryParameters memory,
                         ProcessingGroupParameters group)
Description copied from interface: Schedulable
Set the Scheduler for this Schedulable object.

Specified by:
setScheduler in interface Schedulable
Parameters:
scheduler - a Scheduler value
scheduling - a SchedulingParameters value
release - a ReleaseParameters value
memory - a MemoryParameters value
group - a ProcessingGroupParameters value

setSchedulingParameters

public void setSchedulingParameters(SchedulingParameters scheduling)
Description copied from interface: Schedulable
Set the SchedulingParameters for this Schedulable object only if the resulting task set is feasible.

Specified by:
setSchedulingParameters in interface Schedulable
Parameters:
scheduling - a SchedulingParameters value

setSchedulingParametersIfFeasible

public boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
Description copied from interface: Schedulable
Set the SchedulingParameters for this Schedulable object.

Specified by:
setSchedulingParametersIfFeasible in interface Schedulable
Parameters:
scheduling - a SchedulingParameters value
Returns:
true if the change was feasible, false otherwise

setProcessingGroupParameters

public void setProcessingGroupParameters(ProcessingGroupParameters group)
Description copied from interface: Schedulable
Set the ProcessingGroupParameters for this Schedulable object.

Specified by:
setProcessingGroupParameters in interface Schedulable
Parameters:
group - a ProcessingGroupParameters value

setDaemon

public final void setDaemon(boolean on)

run

public final void run()
Used by the asynchronous event mechanism, see AsyncEvent. This method invokes handleAsyncEvent() repeatedly while the fire count is greater than zero. Applications cannot override this method and should thus override handleAsyncEvent() in subclasses with the logic of the handler.

Specified by:
run in interface Runnable

finalize

protected void finalize()

executionEligibility

public int executionEligibility()


jRate is developed and maintained by the jRate project development team.
Copyright (c) 2001-2006 Angelo Corsaro and Morgan Deters.