]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Ensure ExperimentUtil.scheduleShutdownActiveExperiment invokes callback 19/519/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Sat, 13 May 2017 10:18:29 +0000 (13:18 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Sat, 13 May 2017 10:37:02 +0000 (13:37 +0300)
This needs to be done because calling parties may rely on getting the
callback.

refs #7220

Change-Id: Ie81c20da8da9d734afe7f98cf1117176b2f2dc9d

bundles/org.simantics.db.common/src/org/simantics/db/common/service/ServiceActivityMonitorImpl.java
bundles/org.simantics.simulation/src/org/simantics/simulation/experiment/ExperimentUtil.java

index 1858e87ddea8af1249af7343f95cb1a2037548ae..541380dc59e250567a0ad647e5829c2e9d7fdf13 100644 (file)
@@ -5,12 +5,16 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.simantics.db.service.ServiceActivityMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.TObjectIntMap;
 import gnu.trove.map.hash.TObjectIntHashMap;
 
 public class ServiceActivityMonitorImpl implements ServiceActivityMonitor {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceActivityMonitorImpl.class);
+
     public static final long REPORTING_PERIOD = 5L;
     
     Semaphore sem = new Semaphore(1);
@@ -46,8 +50,8 @@ public class ServiceActivityMonitorImpl implements ServiceActivityMonitor {
             if(waitForCompletion(REPORTING_PERIOD, TimeUnit.SECONDS))
                 return;
             synchronized (ids) {
-                System.err.println("ServiceActivityMonitorImpl.waitForCompletion: " + ids);
-            }    
+                LOGGER.info("waitForCompletion: " + ids);
+            }
         }
     }
 
index a819ef8ed915462da196d5e120ceee3a6a070021..ecf7f0a9ae82ee8d42cce99e67c996dbab2ed446 100644 (file)
@@ -136,17 +136,19 @@ public final class ExperimentUtil {
                 protected IStatus run(final IProgressMonitor monitor) {
                     try {
                         experiment.shutdown(monitor);
-                        if (callback != null)
-                            callback.accept(null);
                         return Status.OK_STATUS;
                     } finally {
                         monitor.done();
+                        if (callback != null)
+                            callback.accept(null);
                     }
                 }
             };
             job.setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
             job.setUser(true);
             job.schedule();
+        } else {
+            callback.accept(null);
         }
     }