public final class Signal extends AsyncEvent implements ActiveEvent<Signal,SignalDispatcher>
ActiveEvent
subclass for defining a POSIX signal.Modifier and Type | Field and Description |
---|---|
static int |
MAX_NUM_SIGNALS
Obtains the number of signals that can be processed.
|
Modifier and Type | Method and Description |
---|---|
void |
addHandler(AsyncBaseEventHandler handler)
addHandler adds a handler to this event.
|
void |
disable()
Change the state of the event so that the associated handlers
are skipped on fire.
|
void |
enable()
Change the state of the event so that associated handlers
are released on fire.
|
static Signal |
get(int id)
Gets a supported signal by its ID.
|
static Signal |
get(String name)
Gets a supported signal by its name.
|
SignalDispatcher |
getDispatcher()
Obtains the dispatcher for
this . |
int |
getId()
Gets the number of this signal.
|
static int |
getId(String name)
Gets the ID of a supported signal by its name.
|
String |
getName()
Gets the name of this signal.
|
static long |
getProcessId()
Obtains the OS Id of the JVM process.
|
boolean |
isActive()
Determines the activation state of this signal,
i.e., whether or not it has been started.
|
static boolean |
isPOSIXSignal(String name)
Determines if a signal with a given name is registered.
|
boolean |
isRunning()
Determines the firing state, releasing or skipping, of this signal,
i.e., whether or not it is active and enabled.
|
void |
removeHandler(AsyncBaseEventHandler handler)
removeHandler removes a handler from this event that was
previously added by addHandler.
|
void |
send(long pid)
Sends this signal to another process or process group.
|
void |
setHandler(AsyncBaseEventHandler handler)
setHandler removes all handlers from the list of handlers for
this event and adds the given handler.
|
void |
start()
Starts this
Signal , i.e., changes to a running state. |
void |
start(boolean disabled)
Starts this
Signal , i.e., changes to a running state. |
boolean |
stop()
Stops this
Signal . |
addHandler, bindTo, createReleaseParameters, fire, handledBy, handledBy, removeHandler, setHandler, unbindTo
hasHandlers
public static final int MAX_NUM_SIGNALS
public static boolean isPOSIXSignal(String name)
UnsupportedOperationException
- everytime, since this is not implemented yet.name
- The string passed as the name of the signal.true
when a signal with the given name is registered.public static int getId(String name)
UnsupportedOperationException
- everytime, since this is not implemented yet.name
- The name
of the signal for which to search.name
.public static Signal get(String name)
UnsupportedOperationException
- everytime, since this is not implemented yet.name
- The name
identifying the signal to get.name
or null
.public static Signal get(int id)
UnsupportedOperationException
- everytime, since this is not implemented yet.id
- The identifier of a registered signal.ID
or null
.public static long getProcessId()
send(long)
.UnsupportedOperationException
- everytime, since this is not implemented yet.ID
.public int getId()
UnsupportedOperationException
- everytime, since this is not implemented yet.public String getName()
UnsupportedOperationException
- everytime, since this is not implemented yet.public SignalDispatcher getDispatcher()
this
.getDispatcher
in interface Releasable<Signal,SignalDispatcher>
UnsupportedOperationException
- everytime, since this is not implemented yet.public boolean isActive()
isActive
in interface ActiveEvent<Signal,SignalDispatcher>
UnsupportedOperationException
- everytime, since this is not implemented yet.true
when active; false
otherwise.public boolean isRunning()
isRunning
in interface ActiveEvent<Signal,SignalDispatcher>
isRunning
in class AsyncBaseEvent
UnsupportedOperationException
- everytime, since this is not implemented yet.true
when releasing, false
when skipping.public void start() throws StaticIllegalStateException
Signal
, i.e., changes to a running state.
A running signal is a source of activation when in a scoped memory
and is a member of the root set when in the heap. A running
signal can be triggered.start
in interface ActiveEvent<Signal,SignalDispatcher>
StaticIllegalStateException
- when this
Signal
has already been started.UnsupportedOperationException
- everytime, since this is not implemented yet.stop()
public void start(boolean disabled) throws StaticIllegalStateException
Signal
, i.e., changes to a running state.
A running signal is a source of activation when in a scoped memory
and is a member of the root set when in the heap. A running
signal can be triggered.start
in interface ActiveEvent<Signal,SignalDispatcher>
StaticIllegalStateException
- when this
Signal
has already been started.UnsupportedOperationException
- everytime, since this is not implemented yet.disabled
- true
for starting in a disabled state.stop()
public boolean stop() throws StaticIllegalStateException
Signal
. A stopped signal
ceases to be a source of activation and no longer causes any AE attached
to it to be a source of activation.stop
in interface ActiveEvent<Signal,SignalDispatcher>
StaticIllegalStateException
- when this
Signal
is not running.UnsupportedOperationException
- everytime, since this is not implemented yet.true
when this
was enabled and
false
otherwise.public void send(long pid) throws POSIXInvalidSignalException, POSIXSignalPermissionException, POSIXInvalidTargetException
On POSIX systems running in user space, the following holds:
POSIX.1-2001 requires the underlying mechanism of signal.send(-1)
to send signal
to all processes for which the current process may
signal, except possibly for some OS-defined system processes.
For an RTVM running in kernel space, the meaning of the pid
is implementation dependent, though it should be as closed to the standard
definition as possible.
POSIXInvalidSignalException
- when the signal number is not valid.POSIXSignalPermissionException
- when the process does not have permission to send the target.POSIXInvalidTargetException
- when the target does not exist.UnsupportedOperationException
- everytime, since this is not implemented yet.pid
- ID of the process to which to send the signal.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 AsyncEvent
UnsupportedOperationException
- everytime, since this is not implemented yet.handler
- the new handler.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 AsyncEvent
UnsupportedOperationException
- everytime, since this is not implemented yet.handler
- The handler to be added, null if none.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 AsyncEvent
UnsupportedOperationException
- everytime, since this is not implemented yet.handler
- the handler to be removed. If this handler is
null or has not been added to this event, nothing will happen.public void enable()
enable
in interface ActiveEvent<Signal,SignalDispatcher>
enable
in class AsyncBaseEvent
UnsupportedOperationException
- everytime, since this is not implemented yet.public void disable()
disable
in interface ActiveEvent<Signal,SignalDispatcher>
disable
in class AsyncBaseEvent
UnsupportedOperationException
- everytime, since this is not implemented yet.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.