public class AsyncEvent extends AsyncBaseEvent
Jamaica Real-Time Specification for Java class AsyncEvent.
An instance of AsyncEvent binds an external event (a happening) to a set of AbstractAsyncEventHandlers. Whenever the external event is fired, the fire count of all event handlers associated with this event will be increased and the handlers will be released.
Constructor and Description |
---|
AsyncEvent()
Constructor constructs a new AsyncEvent that is not bound to any
signal.
|
Modifier and Type | Method and Description |
---|---|
void |
addHandler(AsyncBaseEventHandler handler)
addHandler adds a handler to this event.
|
void |
addHandler(AsyncEventHandler handler)
addHandler adds a handler to this event.
|
void |
bindTo(String happening)
bindTo bind this handler to a happening that is identified by a
platform-dependent string.
|
ReleaseParameters |
createReleaseParameters()
createReleaseParameters creates the default release parameters
for this event.
|
void |
fire()
fire this event once.
|
boolean |
handledBy(AsyncBaseEventHandler handler)
handledBy tests if this event is handled by a given handler.
|
boolean |
handledBy(AsyncEventHandler handler)
handledBy tests if this event is handled by a given handler.
|
void |
removeHandler(AsyncBaseEventHandler handler)
removeHandler removes a handler from this event that was
previously added by addHandler.
|
void |
removeHandler(AsyncEventHandler handler)
removeHandler removes a handler from this event that was
previously added by addHandler.
|
void |
setHandler(AsyncBaseEventHandler handler)
setHandler removes all handlers from the list of handlers for
this event and adds the given handler.
|
void |
setHandler(AsyncEventHandler handler)
setHandler removes all handlers from the list of handlers for
this event and adds the given handler.
|
void |
unbindTo(String happening)
unbindTo removes the binding to a certain happening.
|
disable, enable, hasHandlers, isRunning
public AsyncEvent()
public void addHandler(AsyncBaseEventHandler handler)
addHandler adds a handler to this event. If the handler has already been added, this is a nop.
Since a reference to handler has to be stored in this, an IllegalAssignmentError will be caused if handler is allocated in a memory area that does not permit to be stored in an object allocated in this' memory area.
This call will allocate a small object in the memory area this was allocated in.
The execution of addHandler is atomic with respect to removeHandler and fire.
ensures
(handler != null) ==> (handledBy(handler));
addHandler
in class AsyncBaseEvent
StaticIllegalArgumentException
- if handler == null;handler
- the new handler.public void addHandler(AsyncEventHandler handler)
addHandler adds a handler to this event. If the handler has already been added, this is a nop.
This method has been replaced in RTSJ 2.0 to support the more generic AsyncBaseEventHandler and is kept for binary compatibility.
addHandler(AsyncBaseEventHandler)
public void removeHandler(AsyncBaseEventHandler handler)
removeHandler removes a handler from this event that was previously added by addHandler.
The execution of removeHandler is atomic with respect to addHandler, setHandler, handledBy, and fire.
ensures
((handler == null) || !handledBy(handler));
removeHandler
in class AsyncBaseEvent
handler
- the handler to be removed. If this handler is
null or has not been added to this event, nothing will happen.public void removeHandler(AsyncEventHandler handler)
removeHandler removes a handler from this event that was previously added by addHandler.
This method has been replaced in RTSJ 2.0 to support the more generic AsyncBaseEventHandler and is kept for binary compatibility.
removeHandler(AsyncBaseEventHandler)
public boolean handledBy(AsyncBaseEventHandler handler)
handledBy
in class AsyncBaseEvent
handler
- The handler, may be null.public boolean handledBy(AsyncEventHandler handler)
handledBy(AsyncBaseEventHandler)
public void setHandler(AsyncBaseEventHandler handler)
setHandler removes all handlers from the list of handlers for this event and adds the given handler.
The execution of setHandler is atomic with respect to addHandler, removeHandler, handledBy, and fire.
ensures
((handler == null) || handledBy(handler));
setHandler
in class AsyncBaseEvent
handler
- The handler to be added, null if none.public void setHandler(AsyncEventHandler handler)
setHandler(AsyncBaseEventHandler)
public ReleaseParameters createReleaseParameters()
createReleaseParameters creates the default release parameters for this event. The default implementation creates AperiodicParameters without cost/ deadline and without overrun or miss handler.
createReleaseParameters
in class AsyncBaseEvent
public void bindTo(String happening) throws UnknownHappeningException
bindTo bind this handler to a happening that is identified by a platform-dependent string. Integer numbers 1 through POSIXSignalHandler.MAX_SIGNAL_NR bind this event to the corresponding POSIX event.
When this is allocated in ScopedMemory, then the reference count of MemoryArea.getMemoryArea(this) is incremented until this will be unbound from the happening.
StaticIllegalArgumentException
- if happening is null.UnknownHappeningException
- if happening is not supported.happening
- A platform-dependent string to identify the
happening that causes this event.public void unbindTo(String happening) throws UnknownHappeningException
unbindTo removes the binding to a certain happening.
When this is allocated in ScopedMemory, then the reference count of MemoryArea.getMemoryArea(this) is decremented.
StaticIllegalArgumentException
- if happening is null.UnknownHappeningException
- if happening is not supported
or it was not bound to this event via bindTo().happening
- A platform-dependent string to identify the
happening that causes this event.public void fire() throws MITViolationException, ArrivalTimeQueueOverflowException
fire this event once. All event handlers that were added to this event will be released. If this event is bound to an external happening, it may still be fired manually by a call to this method.
If one or several handlers released by the call to fire cause an ArrivalTimeQueueOverflowException, all the handlers not affected by the exception will still be released normally.
If the release of the handlers requires both, a MITViolationException (due to a handler with SporadicParameters) and an ArrivalTimeQueueOverflowException, this method will throw the MITViolationException.
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.