X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FLogicExecuter.java;fp=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FLogicExecuter.java;h=eb8a72359c533eaf78ecaf3442ac8f71fbcf7311;hb=779f7f8ed5a1fced1ef520e905b2b6c622ac719a;hp=fadfbe94da54e526ec320989882feac8df54e47f;hpb=c8cbe32c51c3d8a722f86477a1f3557140a79a4b;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicExecuter.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicExecuter.java index fadfbe94..eb8a7235 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicExecuter.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicExecuter.java @@ -31,30 +31,36 @@ public class LogicExecuter { isRunningLive.notify(); } - while (shouldBeRunningLive.get()) + try { - // always execute to keep timeline from "hanging behind" for too long - long current = System.currentTimeMillis(); - timeline.executeUntil(timeline.laterThan(current), current + 10); - long sleepTime; - if (timeline.hasNext()) - sleepTime = timeline.nextEventTime() - current; - else - sleepTime = 10000; - try + while (shouldBeRunningLive.get()) { - nextExecSimulTime.set(current + sleepTime); - if (sleepTime > 0) - Thread.sleep(sleepTime); - } - catch (@SuppressWarnings("unused") InterruptedException e) - {// do nothing; it is normal execution flow to be interrupted + // always execute to keep timeline from "hanging behind" for too long + long current = System.currentTimeMillis(); + timeline.executeUntil(timeline.laterThan(current), current + 10); + long sleepTime; + if (timeline.hasNext()) + sleepTime = timeline.nextEventTime() - current; + else + sleepTime = 10000; + try + { + nextExecSimulTime.set(current + sleepTime); + if (sleepTime > 0) + Thread.sleep(sleepTime); + } + catch (@SuppressWarnings("unused") InterruptedException e) + {// do nothing; it is normal execution flow to be interrupted + } } } - isRunningLive.set(false); - synchronized (isRunningLive) + finally { - isRunningLive.notify(); + isRunningLive.set(false); + synchronized (isRunningLive) + { + isRunningLive.notify(); + } } }); timeline.addEventAddedListener(event ->