]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fixed another source of deadlocks in DynamicExperimentThread. 09/2309/2
authorReino Ruusu <reino.ruusu@semantum.fi>
Fri, 12 Oct 2018 11:39:29 +0000 (14:39 +0300)
committerReino Ruusu <reino.ruusu@semantum.fi>
Mon, 15 Oct 2018 08:24:03 +0000 (11:24 +0300)
gitlab #136

Change-Id: Iabeef360c93d617a38cbc7883533c3cb487ae6f2

bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/DynamicExperimentThread.java

index 836c7920f4487e70490a581cc6a0d8bc1a434fea..9ee57f51055aec994a49d33f08726fec5a21c9ca 100644 (file)
@@ -125,7 +125,7 @@ abstract public class DynamicExperimentThread extends Thread {
                                runTasks();
                                taskTime += System.nanoTime() - asd2;
 
-                               System.err.println(" st = " + 1e-9*stepTime + " tt = " + 1e-9*taskTime);
+                               //System.err.println(" st = " + 1e-9*stepTime + " tt = " + 1e-9*taskTime);
 
                                while(obtainedRealtimeRatio > desiredRealtimeRatio) {
                                        int ran = runTasks();
@@ -138,10 +138,12 @@ abstract public class DynamicExperimentThread extends Thread {
 
                                                if(deltaNs > 0) {
                                                        synchronized(tasks) {
-                                                               try {
-                                                                       tasks.wait(deltaMs, deltaNsRem);
-                                                               } catch (InterruptedException e) {
-                                                                       e.printStackTrace();
+                                                               if (inState(StandardExperimentStates.Running.class)) {
+                                                                       try {
+                                                                               tasks.wait(deltaMs, deltaNsRem);
+                                                                       } catch (InterruptedException e) {
+                                                                               LOGGER.warn("Dynamic experiment thread '" + this.getName() + "' (" + this.getClass().getName() + ") interrupted", e);
+                                                                       }
                                                                }
                                                        }
                                                }
@@ -158,7 +160,7 @@ abstract public class DynamicExperimentThread extends Thread {
                                                        try {
                                                                tasks.wait(Integer.MAX_VALUE);
                                                        } catch (InterruptedException e) {
-                                                               e.printStackTrace();
+                                                               LOGGER.warn("Dynamic experiment thread '" + this.getName() + "' (" + this.getClass().getName() + ") interrupted", e);
                                                        }
                                                }
                                        }