public abstract class AsyncBaseEvent
extends java.lang.Object
AsyncEvent with
AsyncLongEvent and AsyncObjectEvent.
Note that when this class is collected, all its handlers are
automatically removed as if setHandler(javax.realtime.AsyncBaseEventHandler) was called with a
null parameter.
| Modifier and Type | Method and Description |
|---|---|
void |
addHandler(AsyncBaseEventHandler handler)
Adds a handler to the set of handlers associated with this event.
|
ReleaseParameters<?> |
createReleaseParameters()
Creates a
ReleaseParameters object appropriate to the
release characteristics of this event. |
void |
disable()
Changes the state of the event so that associated handlers are
skipped on fire.
|
void |
enable()
Changes the state of the event so that associated handlers are
released on fire.
|
boolean |
handledBy(AsyncBaseEventHandler handler)
Determines whether or not the handler given as the parameter is
associated with
this. |
boolean |
hasHandlers()
Determines whether or not this event has any handlers.
|
boolean |
isRunning()
Determines the firing state (releasing or skipping) of this event,
i.e., whether it is enabled or disabled.
|
void |
removeHandler(AsyncBaseEventHandler handler)
Removes a handler from the set associated with this event.
|
void |
setHandler(AsyncBaseEventHandler handler)
Associates a new handler with this event and removes all existing
handlers.
|
public boolean isRunning()
true when releasing, false when skipping.public boolean handledBy(AsyncBaseEventHandler handler)
this.handler - The handler to be tested to determine if it is associated with
this.this. False
when handler is null or the parameters is
not associated with this.public void enable()
public void disable()
public void addHandler(AsyncBaseEventHandler handler)
AsyncBaseEvent may have more than one
associated handler. However, adding a handler to an event has no
effect when the handler is already attached to the event.
The execution of this method is atomic with respect to the execution of the
fire() method.
Note that there is an implicit reference to the handler stored in
this. The assignment must be valid under any applicable memory
assignment rules.
handler - The new handler to add to the list of handlers already
associated with this.
When handler is already associated with
the event, the call has no effect.StaticIllegalArgumentException - when handler is null or the handler has
PeriodicParameters. Only the subclass
PeriodicTimer is allowed to have handlers with
PeriodicParameters.IllegalAssignmentError - when this AsyncBaseEvent cannot hold a reference to
handler.StaticIllegalStateException - when the configured Scheduler
and SchedulingParameters for handler are
not compatible with one another.ScopedCycleException - when handler has an explicit initial
scoped memory area that has already been entered from a memory
area other than the area where handler was allocated.public void setHandler(AsyncBaseEventHandler handler)
fire() method.handler - The instance of AsyncBaseEventHandler to be
associated with this. When handler is
null then no handler will be associated with this,
i.e., it behaves effectively as if setHandler(null)
invokes removeHandler(AsyncBaseEventHandler) for each
associated handler.StaticIllegalArgumentException - when handler has PeriodicParameters. Only
the subclass PeriodicTimer is allowed to have handlers
with PeriodicParameters.IllegalAssignmentError - when this AsyncBaseEvent cannot hold a reference to
handler.public void removeHandler(AsyncBaseEventHandler handler)
fire() method.
A removed handler continues to execute until its fireCount becomes zero and it completes.
When handler has a scoped non-default initial memory area and
execution of this method causes handler to become
unfirable, this method shall not return until all related finalization
has completed.
handler - The handler to be disassociated from this. When
null nothing happens.
When the handler is not already associated with
this then nothing happens.public boolean hasHandlers()
true when and only when at least one handler is associated
with this event.public ReleaseParameters<?> createReleaseParameters()
ReleaseParameters object appropriate to the
release characteristics of this event. The default is the most
pessimistic: AperiodicParameters. This is typically called
by code that is setting up a handler for this event that will fill
in the parts of the release parameters for which it has values,
e.g., cost. The returned ReleaseParameters object is not
bound to the event. Any changes in the event's release parameters
are not reflected in previously returned objects.
When an event returns PeriodicParameters, there is no requirement
for an implementation to check that the handler is released periodically.
ReleaseParameters object.