|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnl.tudelft.ewi.alg.distsim.DProcess<M>
M
- The message payload to be sent around. Can be any type.public abstract class DProcess<M>
Subclasses of this class implement the distributed algorithm.
All work should be done in the receiveMessage
method.
To indicate that the algorithm has work of its own to do, without needing to
be activated by a message, let isDone
return false
.
Then, receiveMessage
will be called with a null
message
if there is indeed no incoming message, allowing this work to be done.
Whenever the algorithm would do a non-blocking receive, return from
receiveMessage
with isDone
returning false
.
To instead do a blocking receive, have isDone
return true
.
In this latter case, receiveMessage
will only be called
if there is an actual message incoming.
Field Summary | |
---|---|
int |
id
|
protected MasterProcess<M> |
masterProc
|
Constructor Summary | |
---|---|
protected |
DProcess(MasterProcess<M> master,
int id)
|
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
|
long |
getClock()
|
long |
getIdle()
|
MasterProcess<?> |
getMasterProcess()
|
int |
hashCode()
|
abstract boolean |
isDone()
Whether or not this process is done. |
protected void |
log(java.lang.String str)
Log something, including a timestamp. |
protected abstract void |
receiveMessage(int senderID,
M message)
Subclasses need to implement this. |
protected void |
sendMessage(int receiverID,
M payload)
Send a message. |
protected void |
setClock(long value)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int id
protected final MasterProcess<M> masterProc
Constructor Detail |
---|
protected DProcess(MasterProcess<M> master, int id)
Method Detail |
---|
protected void setClock(long value)
public long getClock()
public long getIdle()
protected void sendMessage(int receiverID, M payload)
receiverID
- the ID of the receiver of the messagepayload
- the messageprotected void log(java.lang.String str)
str
- the string to log.protected abstract void receiveMessage(int senderID, M message)
senderID
- the sender of the messagemessage
- the message received.public abstract boolean isDone()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public MasterProcess<?> getMasterProcess()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |