|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.zcu.fav.kiv.jsim.ipc.JSimMessageBox
public class JSimMessageBox
A message box is a data structure able to keep messages sent between processes. Every J-Sim process has its own message box that serves as a message store for messages sent directly to the process. However, a message box can be also created explicitly by the user to provide a mean of indirect communication where neither the sender nor the receiver need to be known to the opposite side.
Field Summary | |
---|---|
private static java.util.logging.Logger |
logger
Common logger for all instances of this class. |
protected java.util.LinkedList<JSimMessage> |
messages
A list of all messages that this message box keeps. |
private java.lang.String |
myName
This message box's name. |
protected java.util.LinkedList<JSimProcess> |
suspendedReceivers
A list of all processes that got suspended when they tried to receive a message from this message box. |
protected java.util.LinkedList<JSimProcess> |
suspendedSenders
A list of all processes that got suspended when they sent a message to this message box. |
Constructor Summary | |
---|---|
JSimMessageBox(java.lang.String name)
Creates a new message box with the specified name. |
Method Summary | |
---|---|
void |
addMessage(JSimMessage message)
Adds a new message to the message box. |
void |
addSuspendedReceiver(JSimProcess receiver)
Adds a new process to the collection of processes suspended on receiving a message. |
void |
addSuspendedSender(JSimProcess sender)
Adds a new process to the collection of processes suspended on sending a message. |
boolean |
containsSuspendedSender(JSimProcess sender)
Indicates whether the specified process is among senders suspended on this message box. |
JSimMessage |
getFirstMessage()
Returns the first message in the message box and removes it from there. |
JSimMessage |
getFirstMessageForReceiver(JSimProcess receiver)
Return the first message whose receiver is equal to the specified receiver. |
JSimMessage |
getFirstMessageFromAndFor(JSimProcess possibleSender,
JSimProcess possibleReceiver)
Returns the first message whose receiver is equal to the specified receiver and whose sender is equal to the specified sender. |
JSimMessage |
getFirstMessageFromSender(JSimProcess sender)
Return the first message whose sender is equal to the specified sender. |
JSimProcess |
getFirstSuspendedReceiver(JSimProcess possibleReceiver,
JSimProcess possibleSender)
Returns the first process that is suspended on receiving a message from this message box. |
java.lang.String |
getName()
Returns the name of the message box. |
int |
getNumberOfMessages()
Returns the number of messages in the message box. |
boolean |
isEmpty()
Indicates whether this message box is empty. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.util.logging.Logger logger
private java.lang.String myName
protected java.util.LinkedList<JSimMessage> messages
protected java.util.LinkedList<JSimProcess> suspendedSenders
protected java.util.LinkedList<JSimProcess> suspendedReceivers
Constructor Detail |
---|
public JSimMessageBox(java.lang.String name)
name
- The name of the message box.Method Detail |
---|
public java.lang.String getName()
public void addMessage(JSimMessage message) throws JSimInvalidParametersException
message
- The message to be added to the box.
JSimInvalidParametersException
- This exception is thrown out if the specified message is null.public JSimMessage getFirstMessage()
public JSimMessage getFirstMessageFromSender(JSimProcess sender) throws JSimInvalidParametersException
sender
- The process that sent the message we are looking for. Must not be null.
JSimInvalidParametersException
- This exception is thrown out if the sender is not specified.public JSimMessage getFirstMessageForReceiver(JSimProcess receiver) throws JSimInvalidParametersException
receiver
- The process that the message we are looking for was sent to. Must not be null.
JSimInvalidParametersException
- This exception is thrown out if the receiver is not specified.public JSimMessage getFirstMessageFromAndFor(JSimProcess possibleSender, JSimProcess possibleReceiver)
possibleSender
- The sender of the message we are looking for, or UNKNOWN_SENDER for any sender.possibleReceiver
- The receiver of the message we are looking for, or UNKNOWN_RECEIVER for any receiver.
public int getNumberOfMessages()
public boolean isEmpty()
public boolean containsSuspendedSender(JSimProcess sender) throws JSimInvalidParametersException
sender
- The sender that is or is not among suspended senders. Must not be null.
JSimInvalidParametersException
- This exception is thrown out if the sender is not specified (null).public JSimProcess getFirstSuspendedReceiver(JSimProcess possibleReceiver, JSimProcess possibleSender)
possibleReceiver
- A process that can be returned by this method or UNKNOWN_RECEIVER for any receiver.possibleSender
- A process that the selected process must be waiting for of UNKNOWN_SENDER for any sender. If a suspended process has not
its waiting-for-sender specified, this value will be ignored for the suspended process.
public void addSuspendedSender(JSimProcess sender) throws JSimInvalidParametersException
sender
- The process getting blocked on sending a message via this message box.
JSimInvalidParametersException
- This exception is thrown out if the sender is not specified.public void addSuspendedReceiver(JSimProcess receiver) throws JSimInvalidParametersException
receiver
- The process getting blocked on receiving a message via this message box.
JSimInvalidParametersException
- This exception is thrown out if the receiver is not specified.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |