|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.sc.ants.Environment.RunningThing
This class embodies one running thing (i.e. agent). Its methods are all synchronized because we do not want the environment to be reading and writing at the same time to one of the variables. That is, since each agent can call the Environment from its own thread it is possible that two agent threads could try to modify the one RunningThing at the same time. Specifically, one agent could try to send a message to a second one at the same time that the second one is trying to read it, or some third agent might be also be trying to send a message to the second agent.
Field Summary | |
(package private) int |
bufferSize
|
(package private) int |
headMessage
the one that is returned. |
(package private) Observation |
location
The real position of this agent |
(package private) Message[] |
messages
The agent's mailbox of messages. |
(package private) int |
tailMessage
add new message here |
(package private) Thing |
thing
The thing we refer to |
(package private) java.lang.Thread |
thread
The thread on which it runs |
Constructor Summary | |
Environment.RunningThing(Thing t)
Add a new thing. |
Method Summary | |
void |
addMessage(Message v)
Appends the given message to the mailbox |
Observation |
getLocation()
Get the value of location. |
Observation |
getLocationCopy()
Return a copy of the current location. |
Message |
getMessage()
Get the next message |
Thing |
getThing()
Get the value of thing. |
java.lang.Thread |
getThread()
Get the value of thread. |
void |
setLocation(Observation v)
Set the value of location. |
void |
setThing(Thing v)
Set the value of thing. |
void |
setThread(java.lang.Thread v)
Set the value of thread. |
Methods inherited from class java.lang.Object |
|
Field Detail |
Thing thing
java.lang.Thread thread
Message[] messages
int headMessage
int tailMessage
int bufferSize
Observation location
Constructor Detail |
public Environment.RunningThing(Thing t)
Method Detail |
public Thing getThing()
public void setThing(Thing v)
v
- Value to assign to thing.public java.lang.Thread getThread()
public void setThread(java.lang.Thread v)
v
- Value to assign to thread.public Message getMessage()
public void addMessage(Message v)
v
- Value to assign to message.public Observation getLocation()
public Observation getLocationCopy()
public void setLocation(Observation v)
v
- Value to assign to location.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |