From: Tuukka Lehtonen Date: Sat, 13 May 2017 10:18:29 +0000 (+0300) Subject: Ensure ExperimentUtil.scheduleShutdownActiveExperiment invokes callback X-Git-Tag: v1.29.0~51 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=7de0f58a6d781fb963e7b90bf1307de20d5ad037 Ensure ExperimentUtil.scheduleShutdownActiveExperiment invokes callback This needs to be done because calling parties may rely on getting the callback. refs #7220 Change-Id: Ie81c20da8da9d734afe7f98cf1117176b2f2dc9d (cherry picked from commit 51239a7b24d812eec59b7f635ed0cfd9d116a268) --- diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/service/ServiceActivityMonitorImpl.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/service/ServiceActivityMonitorImpl.java index 1858e87dd..541380dc5 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/service/ServiceActivityMonitorImpl.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/service/ServiceActivityMonitorImpl.java @@ -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); + } } } diff --git a/bundles/org.simantics.simulation/src/org/simantics/simulation/experiment/ExperimentUtil.java b/bundles/org.simantics.simulation/src/org/simantics/simulation/experiment/ExperimentUtil.java index a819ef8ed..ecf7f0a9a 100644 --- a/bundles/org.simantics.simulation/src/org/simantics/simulation/experiment/ExperimentUtil.java +++ b/bundles/org.simantics.simulation/src/org/simantics/simulation/experiment/ExperimentUtil.java @@ -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); } }