From 47c6b1ed3cc26b5b07c790ba10ed1472c40c6247 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Fri, 12 Jul 2013 02:17:47 -0500 Subject: [PATCH] Added check to Trim process to make sure it doesn't drag on for too long per tick; shouldn't normally be possible on Trim process as opposed to Fill process, but I've had a couple of reports indicating it might rarely be an issue --- .../java/com/wimbli/WorldBorder/WorldTrimTask.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/wimbli/WorldBorder/WorldTrimTask.java b/src/main/java/com/wimbli/WorldBorder/WorldTrimTask.java index 4cf6e5c..806ac2c 100644 --- a/src/main/java/com/wimbli/WorldBorder/WorldTrimTask.java +++ b/src/main/java/com/wimbli/WorldBorder/WorldTrimTask.java @@ -97,6 +97,8 @@ public class WorldTrimTask implements Runnable // this is set so it only does one iteration at a time, no matter how frequently the timer fires readyToGo = false; + // and this is tracked to keep one iteration from dragging on too long and possibly choking the system if the user specified a really high frequency + long loopStartTime = Config.Now(); counter = 0; while (counter <= chunksPerRun) @@ -105,10 +107,19 @@ public class WorldTrimTask implements Runnable if (paused) return; + long now = Config.Now(); + // every 5 seconds or so, give basic progress report to let user know how it's going - if (Config.Now() > lastReport + 5000) + if (now > lastReport + 5000) reportProgress(); + // if this iteration has been running for 45ms (almost 1 tick) or more, stop to take a breather + if (now > loopStartTime + 45) + { + readyToGo = true; + return; + } + if (regionChunks.isEmpty()) addCornerChunks(); else if (currentChunk == 4)