diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-17 14:55:16 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-17 14:55:16 +0000 |
| commit | 271949bf140359dd97cbee9ef927ee9280c9f31f (patch) | |
| tree | 31cd0e175401d2041e23128402c235eb6d2e3117 /sources/protocols/VSProtocol.java | |
| parent | 5a0924146201bc577ca170952a21a42464ac7c71 (diff) | |
Vectortimestamps work
Better representation of Lamporttimestamps
BerkelyTimeProtocol
M trunk/ROADMAP
M trunk/sources/prefs/VSPrefs.java
M trunk/sources/prefs/VSDefaultPrefs.java
M trunk/sources/simulator/VSMain.java
M trunk/sources/simulator/VSSimulation.java
M trunk/sources/simulator/VSSimulationPanel.java
M trunk/sources/utils/VSFrame.java
M trunk/sources/utils/VSClassLoader.java
M trunk/sources/utils/VSInfoArea.java
M trunk/sources/protocols/BroadcastSturmProtocol.java
M trunk/sources/protocols/ExternalTimeSyncProtocol.java
M trunk/sources/protocols/RegisteredProtocols.java
M trunk/sources/protocols/PingPongProtocol.java
M trunk/sources/protocols/InternalTimeSyncProtocol.java
M trunk/sources/protocols/VSProtocol.java
M trunk/sources/protocols/DummyProtocol.java
A trunk/sources/protocols/BerkelyTimeProtocol.java
M trunk/sources/core/VSLamport.java
M trunk/sources/core/VSProcess.java
A trunk/sources/core/VSTime.java
A trunk/sources/core/VSVectorTime.java
M trunk/sources/core/VSTask.java
M trunk/sources/core/VSMessage.java
M trunk/sources/editors/VSEditor.java
M trunk/sources/editors/VSProtocolEditor.java
M trunk/sources/editors/VSSimulationEditor.java
M trunk/sources/editors/VSEditorFrame.java
M trunk/sources/editors/VSProcessEditor.java
Diffstat (limited to 'sources/protocols/VSProtocol.java')
| -rw-r--r-- | sources/protocols/VSProtocol.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/sources/protocols/VSProtocol.java b/sources/protocols/VSProtocol.java index b66f034..4f34195 100644 --- a/sources/protocols/VSProtocol.java +++ b/sources/protocols/VSProtocol.java @@ -11,9 +11,12 @@ abstract public class VSProtocol extends VSPrefs implements VSEvent { private boolean isClient; protected VSProcess process; private boolean currentContextIsServer; - private boolean lamportIncreased; - public VSProtocol() { + public void init(VSProcess process) { + this.process = process; + this.prefs = process.getPrefs(); + + onInit(); } protected final void setProtocolClassname(String protocolClassname) { @@ -36,7 +39,8 @@ abstract public class VSProtocol extends VSPrefs implements VSEvent { } protected void sendMessage(VSMessage message) { - process.setLamportTime(process.getLamportTime()+1); + process.increaseLamportTime(); + process.increaseVectorTime(); message.setSendingProcess(process); process.sendMessage(message); } @@ -75,14 +79,6 @@ abstract public class VSProtocol extends VSPrefs implements VSEvent { this.isClient = isClient; } - public final void setVSPrefs(VSPrefs prefs) { - this.prefs = prefs; - } - - public final void setProcess(VSProcess process) { - this.process = process; - } - public void reset() { if (isServer) { currentContextIsServer = true; @@ -95,6 +91,7 @@ abstract public class VSProtocol extends VSPrefs implements VSEvent { } } + abstract protected void onInit(); abstract protected void onClientStart(); abstract protected void onClientReset(); abstract protected void onClientRecv(VSMessage message); @@ -110,6 +107,10 @@ abstract public class VSProtocol extends VSPrefs implements VSEvent { return protocol.getID() == getID(); } + protected int getNumProcesses() { + return process.getSimulationPanel().getNumProcesses(); + } + public String toString() { String type = new String(); |
