diff options
| author | Paul Buetow <paul@buetow.org> | 2008-06-03 14:57:27 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-06-03 14:57:27 +0000 |
| commit | f7bdf8a7f6ebd43bfacc22eeeda3eb52bf50efd7 (patch) | |
| tree | 38dba43c074d10466d206cdc07015b3e65735a9e /sources | |
| parent | b65cb84037cec3185aeed8b996455f8e97c17216 (diff) | |
Bugfixes:
VSTaskManager.getGlobalTask did not return all global tasks.
Extra check if a protocol has been initialized.
Diffstat (limited to 'sources')
| -rw-r--r-- | sources/core/VSTaskManager.java | 12 | ||||
| -rw-r--r-- | sources/protocols/VSAbstractProtocol.java | 16 |
2 files changed, 23 insertions, 5 deletions
diff --git a/sources/core/VSTaskManager.java b/sources/core/VSTaskManager.java index 5e32183..272a52c 100644 --- a/sources/core/VSTaskManager.java +++ b/sources/core/VSTaskManager.java @@ -268,7 +268,7 @@ public class VSTaskManager implements VSSerializable { * * @param task the task to insert */ - private void insert(VSTask task) { + private synchronized void insert(VSTask task) { if (task.timeOver()) { if (task.isProgrammed()) fullfilledProgrammedTasks.addLast(task); @@ -286,7 +286,7 @@ public class VSTaskManager implements VSSerializable { * * @param task the task to add */ - public void addTask(VSTask task) { + public synchronized void addTask(VSTask task) { addTask(task, VSTaskManager.ONLY_ONCE); } @@ -328,7 +328,7 @@ public class VSTaskManager implements VSSerializable { * * @param tasks the tasks to remove */ - public void removeAllTasks(ArrayList<VSTask> tasks) { + public synchronized void removeAllTasks(ArrayList<VSTask> tasks) { for (VSTask task : tasks) removeTask(task); } @@ -396,7 +396,7 @@ public class VSTaskManager implements VSSerializable { if (task.isGlobalTimed()) globalTasks.add(task); - for (VSTask task : globalTasks) + for (VSTask task : this.globalTasks) if (task.isProgrammed()) globalTasks.add(task); @@ -453,7 +453,7 @@ public class VSTaskManager implements VSSerializable { /* (non-Javadoc) * @see java.lang.Object#toString() */ - public String toString() { + public synchronized String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(prefs.getString("lang.task.manager")); @@ -467,6 +467,7 @@ public class VSTaskManager implements VSSerializable { } buffer.append(prefs.getString("lang.tasks.global")); + buffer.append(": "); for (VSTask task : globalTasks) { buffer.append(task); @@ -474,6 +475,7 @@ public class VSTaskManager implements VSSerializable { } buffer.append(prefs.getString("lang.tasks.local")); + buffer.append(": "); ArrayList<VSProcess> processes = simulatorCanvas.getProcesses(); synchronized (processes) { diff --git a/sources/protocols/VSAbstractProtocol.java b/sources/protocols/VSAbstractProtocol.java index 30e664c..9999f62 100644 --- a/sources/protocols/VSAbstractProtocol.java +++ b/sources/protocols/VSAbstractProtocol.java @@ -54,6 +54,12 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { /** The protocol object is a client. */ private boolean isClient; + /** The protocol object server is initialized. */ + private boolean isServerInitialized; + + /** The protocol object client is initialized. */ + private boolean isClientInitialized; + /** The current protocol object's context is a server. */ private boolean currentContextIsServer; @@ -105,11 +111,15 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { if (hasOnServerStart) { if (isServer) { currentContextIsServer(true); + if (!isServerInitialized) + onInit(); onServerStart(); } } else { if (isClient) { currentContextIsServer(false); + if (!isClientInitialized) + onInit(); onClientStart(); } } @@ -122,11 +132,13 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { if (isClient) { currentContextIsServer(false); onClientInit(); + isClientInitialized = true; } if (isServer) { currentContextIsServer(true); onServerInit(); + isServerInitialized = true; } } @@ -161,11 +173,15 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { if (isServer) { currentContextIsServer(true); + if (!isServerInitialized) + onInit(); onServerRecv(message); } if (isClient) { currentContextIsServer(false); + if (!isClientInitialized) + onInit(); onClientRecv(message); } } |
