public final class Signal extends AsyncEvent implements ActiveEvent<Signal,SignalDispatcher>
ActiveEvent
subclass for defining a POSIX signal.Modifier and Type | Method and Description |
---|---|
void |
addHandler(AsyncBaseEventHandler handler)
Add a handler to the set of handlers associated with
this event.
|
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()
Obtain the current dispatcher for this event.
|
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.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isActive()
Determines the activation state of this signal,
i.e., whether or not it has been started.
|
boolean |
isRunning()
Determines the firing state, releasing or skipping, of this signal,
i.e., whether or not it is active and enabled.
|
static boolean |
isSignal(int id)
Determines if the given name represents a POSIX signal.
|
static boolean |
isSignal(String name)
Determines if a signal with a given name is registered.
|
void |
removeHandler(AsyncBaseEventHandler handler)
Remove a handler from the set associated with this event.
|
void |
send(long pid)
Sends this signal to another process.
|
SignalDispatcher |
setDispatcher(SignalDispatcher value)
Change the current dispatcher for this event.
|
void |
setHandler(AsyncBaseEventHandler handler)
Associate a new handler with this event and remove all
existing handlers.
|
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 . |
String |
toString()
Returns a string representation of the object.
|
void |
trigger() |
addHandler, bindTo, createReleaseParameters, fire, handledBy, removeHandler, setHandler, unbindTo
disable, enable, finalize, handledBy, hasHandlers
clone, equals, getClass, notify, notifyAll, wait, wait, wait
disable, enable
public static boolean isSignal(String name)
name
- The string passed as the name of the signal.true
when a signal with the given name is registered.public static boolean isSignal(int id)
id
- The int passed as the numerical identifier of the signal.true
when a signal with the given id is defined, but
in all other cases false
.public static int getId(String name)
POSIXInvalidSignalException
- when no signal with the given
name exists or name
is null
.name
- The name
of the signal for which to search.name
.public static Signal get(String name)
POSIXInvalidSignalException
- when no signal with the given
name exists or name
is null
.name
- The name
identifying the signal to get.name
or null
.public static Signal get(int id)
POSIXInvalidSignalException
- when no signal with the given
identifier id
exists.id
- The identifier of a registered signal.ID
or null
.public static long getProcessId()
send(long)
.ID
.public void trigger()
public int getId()
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String getName()
public SignalDispatcher getDispatcher()
getDispatcher
in interface ActiveEvent<Signal,SignalDispatcher>
getDispatcher
in interface Releasable<Signal,SignalDispatcher>
public SignalDispatcher setDispatcher(SignalDispatcher value)
dispatcher
is null
, the default dispatcher is restored.setDispatcher
in interface ActiveEvent<Signal,SignalDispatcher>
public boolean isActive()
isActive
in interface ActiveEvent<Signal,SignalDispatcher>
true
when active; false
otherwise.public boolean isRunning()
isRunning
in interface ActiveEvent<Signal,SignalDispatcher>
isRunning
in class AsyncBaseEvent
true
when releasing, false
when skipping.public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
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.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.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.true
when this
was enabled and
false
otherwise.public void addHandler(AsyncBaseEventHandler handler)
AsyncBaseEvent
addHandler
in class AsyncBaseEvent
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 effectpublic void setHandler(AsyncBaseEventHandler handler)
AsyncBaseEvent
setHandler
in class AsyncBaseEvent
handler
- The instance of AsyncBaseEventHandler to
be associated with this. When handler is
null then no handler will be associated
with this, i.e., behave effectively as if
setHandler(null) invokes
removeHandler(AsyncBaseEventHandler) for
each associated handler.public void removeHandler(AsyncBaseEventHandler handler)
AsyncBaseEvent
removeHandler
in class AsyncBaseEvent
handler
- The handler to be disassociated from this. When
null nothing happens. When the handler is not
already associated with this then nothing happenspublic void send(long pid) throws 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.
POSIXSignalPermissionException
- when the process does not
have permission to send the target.POSIXInvalidTargetException
- when the target does not exist.pid
- The identifier of the process to which to send the signal.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2024 aicas GmbH. All Rights Reserved.