From: David ‘Bombe’ Roden Date: Thu, 27 Mar 2014 15:54:54 +0000 (+0100) Subject: Don’t calculate time more than once. X-Git-Tag: v2~243 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d7ad1bb8808e3937c505eed9d7b3b6a12bd9783b;p=rhynodge.git Don’t calculate time more than once. --- 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! */