Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Phillips2012-11-29 05:04:11 +0000
committerGerrit Code Review @ Eclipse.org2012-12-05 23:48:22 +0000
commit881f36daf6e30259df85234efb7355a44ce5d48c (patch)
treec9799b224f5284e211820147b24a5693fbba72e7
parent0f38ddfdc59b01b8012a8a659d3d06c45e5bc2f5 (diff)
downloadorg.eclipse.osee-881f36daf6e30259df85234efb7355a44ce5d48c.tar.gz
org.eclipse.osee-881f36daf6e30259df85234efb7355a44ce5d48c.tar.xz
org.eclipse.osee-881f36daf6e30259df85234efb7355a44ce5d48c.zip
refinement[bgz_395429]: Fix early unlock threading issue
-rw-r--r--plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/CycleCountDown.java20
-rw-r--r--plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/SimulatedTime.java17
2 files changed, 20 insertions, 17 deletions
diff --git a/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/CycleCountDown.java b/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/CycleCountDown.java
index a6442cacb2f..1f8e8f09c58 100644
--- a/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/CycleCountDown.java
+++ b/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/CycleCountDown.java
@@ -21,6 +21,7 @@ import org.eclipse.osee.ote.core.environment.interfaces.ITimeout;
*/
public class CycleCountDown implements ICancelTimer {
private int cycleCount;
+ private volatile boolean completed;
private final ITimeout objToNotify;
private final IScriptControl scriptLock;
@@ -33,32 +34,33 @@ public class CycleCountDown implements ICancelTimer {
this.scriptLock = scriptLock;
this.cycleCount = cycleCount;
this.objToNotify = objToNotify;
+ this.completed = false;
objToNotify.setTimeout(false);
}
/**
- * @return true if the cycleCount == 0, otherwise false
+ * @return true if the countdown is complete/canceled, otherwise false
*/
public boolean cycleOccurred() {
- if (cycleCount == -1) {
- return true;
- }
- if (cycleCount == 0) {
+ if (cycleCount == 0 && !completed) {
+ completed = true;
synchronized (objToNotify) {
objToNotify.setTimeout(true);
objToNotify.notifyAll();
}
- return true; // so that notify is only called after a countdown becomes zero for the first time
}
- cycleCount--;
- return false;
+ else {
+ cycleCount--;
+ }
+ return completed;
}
@Override
public void cancelTimer() {
- this.cycleCount = -1;
+ this.completed = true;
if (this.scriptLock != null) {
this.scriptLock.lock();
}
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/SimulatedTime.java b/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/SimulatedTime.java
index 204084e5b06..9bf2c4ae08d 100644
--- a/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/SimulatedTime.java
+++ b/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/timer/SimulatedTime.java
@@ -16,6 +16,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
+
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.ote.core.environment.EnvironmentTask;
import org.eclipse.osee.ote.core.environment.TestEnvironment;
@@ -78,21 +79,21 @@ public class SimulatedTime extends TimerControl {
@Override
public ICancelTimer setTimerFor(ITimeout objToNotify, int milliseconds) {
- try {
+ CycleCountDown cycleCountDown = new CycleCountDown(scriptControl, objToNotify,
+ (int) Math.rint(milliseconds / (1000.0 / EnvironmentTask.cycleResolution)) - 1);
+ synchronized (cycleCounters) {
+ cycleCounters.add(cycleCountDown);
+ }
+ try {
scriptControl.unlock();
} catch (IllegalMonitorStateException ex) {
if (!Thread.currentThread().getName().contains("(JSK) mux request dispatch") || !Thread.currentThread().getName().contains(
- "(JSK) Mux request dispatch")) {
+ "(JSK) Mux request dispatch")) {
OseeLog.log(MessageSystemTestEnvironment.class, Level.SEVERE, ex);
}
}
- CycleCountDown cycleCountDown =
- new CycleCountDown(scriptControl, objToNotify,
- (int) Math.rint(milliseconds / (1000.0 / EnvironmentTask.cycleResolution)) - 1);
- synchronized (cycleCounters) {
- cycleCounters.add(cycleCountDown);
- }
+
return cycleCountDown;
}

Back to the top