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

This commit is contained in:
Brettflan 2013-07-12 02:17:47 -05:00
parent 893701637a
commit 47c6b1ed3c

View File

@ -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)