From: David ‘Bombe’ Roden Date: Thu, 14 Oct 2010 09:22:50 +0000 (+0200) Subject: Change restart and wait logic. X-Git-Tag: 0.1-RC1~416 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6e7a48e2c7dcfa3a16fde0f7e475f50ed3a8fb0b;p=Sone.git Change restart and wait logic. --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 307037c..5730b55 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -86,7 +86,13 @@ public class SoneInserter extends AbstractService { @Override protected void serviceRun() { long modificationCounter = 0; + boolean restartNow = true; while (!shouldStop()) { + if (!restartNow) { + logger.log(Level.FINEST, "Waiting 60 seconds before checking Sone “" + sone.getName() + "”."); + sleep(60 * 1000); + } + restartNow = false; InsertInformation insertInformation = null; synchronized (sone) { modificationCounter = sone.getModificationCounter(); @@ -117,12 +123,11 @@ public class SoneInserter extends AbstractService { sone.setModificationCounter(0); } else { logger.log(Level.FINE, "Sone “%s” was modified since the insert started, starting another insert…", new Object[] { sone }); + restartNow = true; } } } } - logger.log(Level.FINEST, "Waiting 60 seconds before checking Sone “" + sone.getName() + "” again."); - sleep(60 * 1000); } }