|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.realtime.AsyncEventHandler
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
SporadicParameters61 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.
Field Summary | |
protected int |
executionEligibility
|
protected gnu.gcj.RawData |
natFireCount_
|
Constructor Summary | |
protected |
AsyncEventHandler()
|
Method Summary | |
protected void |
finalize()
|
protected int |
getAndClearPendingFireCount()
Atomically set to zero the number of pending executions of this handler and returns the value from before it was cleared. |
protected int |
getAndDecrementPendingFireCount()
Atomically decrements the number of pending executions of this handler (if it was non-zero) and returns the value from before the decrement. |
protected int |
getAndIncrementPendingFireCount()
Atomically increments the number of pending executions of this handler and returns the value from before the increment. |
protected int |
getPendingFireCount()
Return the number of pending executions of this handler. |
abstract 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. |
void |
run()
Used by the asynchronous event mechanism, see AsyncEvent . |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected gnu.gcj.RawData natFireCount_
protected int executionEligibility
Constructor Detail |
protected AsyncEventHandler()
Method Detail |
protected int getAndClearPendingFireCount()
public void handleAsyncEvent() {
int fireCount =
getAndClearPendingFireCount();
}
int
value representing the pending fire
count.protected int getAndDecrementPendingFireCount()
handleAsyncEvent()
method in this form to handle
multiple firings:
public void handleAsyncEvent() {
do {
} while(getAndDecrementPendingFireCount()>0);
}
This construction is necessary only in the case where one
wishes to avoid the setup costs since the framework guarantees
that handleAsyncEvent()
will be invoked the
appropriate number of times.
int
value representing the pending fire count.protected int getAndIncrementPendingFireCount()
handleAsyncEvent()
method does not need to do
this, since the surrounding framework guarantees that the
handler will be re-executed the appropriate number of times. It
is only of value when there is common setup code that is
expensive.
int
value representing the pending fire
count.protected int getPendingFireCount()
int
value representing the pending fire
count.public abstract void handleAsyncEvent()
Runnable
objects
run
method is called; This method will be invoked
repeatedly while fireCount
is greater than zero.
public final void run()
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.
run
in interface Runnable
protected void finalize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |