From d7ad1bb8808e3937c505eed9d7b3b6a12bd9783b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 27 Mar 2014 16:54:54 +0100 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20calculate=20time=20more=20than?= =?utf8?q?=20once.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/rhynodge/engine/Engine.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java b/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java index 423eaaf..2ff7666 100644 --- a/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java +++ b/src/main/java/net/pterodactylus/rhynodge/engine/Engine.java @@ -122,14 +122,13 @@ public class Engine extends AbstractExecutionThreadService { /* wait until the next reaction has to run. */ Optional lastState = stateManager.loadLastState(reactionName); - long lastStateTime = lastState.isPresent() ? lastState.get().time() : 0; int lastStateFailCount = lastState.isPresent() ? lastState.get().failCount() : 0; - long waitTime = (lastStateTime + nextReaction.get().getReaction().updateInterval()) - System.currentTimeMillis(); + long waitTime = nextReaction.get().getNextTime() - System.currentTimeMillis(); logger.debug(format("Time to wait for next Reaction: %d millseconds.", waitTime)); if (waitTime > 0) { synchronized (reactions) { try { - logger.info(format("Waiting until %tc.", lastStateTime + nextReaction.get().getReaction().updateInterval())); + logger.info(format("Waiting until %tc.", nextReaction.get().getNextTime())); reactions.wait(waitTime); } catch (InterruptedException ie1) { /* we’re looping! */ -- 2.7.4