summaryrefslogtreecommitdiff
path: root/sources/core
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-17 20:36:00 +0000
committerPaul Buetow <paul@buetow.org>2008-05-17 20:36:00 +0000
commitdbb780b7295c0df60269ee6f3c85c3056d6262b8 (patch)
treed8f084283d6b5b86482e7edb3d7fc786de737ceb /sources/core
parenta622ebff377f37d14535f91e484335e2ad215acb (diff)
VSEvent interface has now has the init method.
Diffstat (limited to 'sources/core')
-rw-r--r--sources/core/VSMessage.java12
-rw-r--r--sources/core/VSProcess.java6
-rw-r--r--sources/core/VSTask.java18
3 files changed, 12 insertions, 24 deletions
diff --git a/sources/core/VSMessage.java b/sources/core/VSMessage.java
index 1ccad7f..1bd4ca6 100644
--- a/sources/core/VSMessage.java
+++ b/sources/core/VSMessage.java
@@ -18,6 +18,12 @@ public class VSMessage extends VSPrefs implements VSEvent {
this.messageID = ++messageCounter;
}
+ public void init(VSProcess process) {
+ this.sendingProcess = process;
+ lamportTime = sendingProcess.getLamportTime();
+ vectorTime = sendingProcess.getVectorTime().getCopy();
+ }
+
public String getProtocolName() {
return VSRegisteredProtocols.getProtocolName(getProtocolClassname());
}
@@ -30,12 +36,6 @@ public class VSMessage extends VSPrefs implements VSEvent {
return messageID;
}
- public void setSendingProcess(VSProcess sendingProcess) {
- this.sendingProcess = sendingProcess;
- lamportTime = sendingProcess.getLamportTime();
- vectorTime = sendingProcess.getVectorTime().getCopy();
- }
-
public VSProcess getSendingProcess() {
return sendingProcess;
}
diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java
index 5c3435e..e3d260e 100644
--- a/sources/core/VSProcess.java
+++ b/sources/core/VSProcess.java
@@ -5,6 +5,7 @@ import java.util.*;
import core.time.*;
import events.*;
+import events.implementations.*;
import prefs.*;
import protocols.*;
import simulator.*;
@@ -225,9 +226,10 @@ public final class VSProcess extends VSPrefs {
taskManager.removeTask(randomCrashTask);
if (crashTime >= 0 && crashTime >= getGlobalTime()) {
- randomCrashTask = new VSTask(crashTime, this, new ProcessCrashEvent());
+ VSProcessEvent event = new ProcessCrashEvent();
+ event.init(this);
+ randomCrashTask = new VSTask(crashTime, this, event);
taskManager.addTask(randomCrashTask);
- //System.out.println("DEBUG " + processID + " crashes at " + crashTime);
} else {
randomCrashTask = null;
diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java
index 26b2485..d481300 100644
--- a/sources/core/VSTask.java
+++ b/sources/core/VSTask.java
@@ -5,7 +5,7 @@ import events.*;
import protocols.VSProtocol;
import simulator.*;
-public class VSTask implements Comparable {
+public class VSTask {
//public final static int RUN_ON_CLIENT_START = 1;
private long taskTime;
private VSEvent event;
@@ -114,7 +114,7 @@ public class VSTask implements Comparable {
private void onProcessEventStart() {
final VSProcessEvent processEvent = (VSProcessEvent) event;
- processEvent.onStart(process);
+ processEvent.onStart();
}
public long getTaskTime() {
@@ -129,20 +129,6 @@ public class VSTask implements Comparable {
process.logg(message);
}
- public int compareTo(Object object) {
- if (object instanceof VSTask) {
- final VSTask task = (VSTask) object;
-
- if (taskTime < task.getTaskTime())
- return -1;
-
- else if (taskTime > task.getTaskTime())
- return 1;
- }
-
- return 0;
- }
-
public String toString() {
String descr = "VSTask: " + getTaskTime();