Fix timers not being Daemonized, preventing MC shutdown
This commit is contained in:
@@ -29,6 +29,8 @@ import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.world.*;
|
||||
@@ -58,7 +60,7 @@ public class SharedApi
|
||||
private static final int MAX_UPDATING_CHUNK_COUNT_PER_THREAD = 500;
|
||||
private static final int MIN_MS_BETWEEN_OVERLOADED_LOG_MESSAGE = 5_000;
|
||||
|
||||
private static final Timer CHUNK_UPDATE_TIMER = new Timer();
|
||||
private static final Timer CHUNK_UPDATE_TIMER = TimerUtil.CreateTimer("ChunkUpdateTimer");
|
||||
|
||||
|
||||
private static AbstractDhWorld currentWorld;
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import com.seibel.distanthorizons.api.enums.rendering.ETransparency;
|
||||
import com.seibel.distanthorizons.core.config.listeners.ConfigChangeListener;
|
||||
import com.seibel.distanthorizons.core.config.listeners.IConfigListener;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -103,7 +104,7 @@ public class RenderCacheConfigEventHandler
|
||||
DhApi.Delayed.renderProxy.clearRenderDataCache();
|
||||
}
|
||||
};
|
||||
this.cacheClearingTimer = new Timer("RenderCacheConfig-Timeout-Timer");
|
||||
this.cacheClearingTimer = TimerUtil.CreateTimer("RenderCacheClearConfigTimer");
|
||||
this.cacheClearingTimer.schedule(timerTask, TIMEOUT_IN_MS);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import com.seibel.distanthorizons.core.config.ConfigBase;
|
||||
import com.seibel.distanthorizons.core.config.ConfigEntryWithPresetOptions;
|
||||
import com.seibel.distanthorizons.core.config.listeners.IConfigListener;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.config.IConfigEntry;
|
||||
import com.seibel.distanthorizons.coreapi.util.StringUtil;
|
||||
@@ -117,7 +118,7 @@ public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<
|
||||
{
|
||||
public void run() { AbstractPresetConfigEventHandler.this.applyPreset(); }
|
||||
};
|
||||
this.applyPresetTimer = new Timer("ApplyPresetTimer");
|
||||
this.applyPresetTimer = TimerUtil.CreateTimer("ApplyConfigPresetTimer");
|
||||
this.applyPresetTimer.schedule(task, MS_DELAY_BEFORE_APPLYING_PRESET);
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||
import com.seibel.distanthorizons.core.sql.*;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStream;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -32,7 +33,7 @@ import java.util.zip.CheckedOutputStream;
|
||||
public abstract class AbstractDataSourceHandler<TDataSource extends IDataSource<TDhLevel>, TDhLevel extends IDhLevel> implements ISourceProvider<TDataSource, TDhLevel>
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
private static final Timer DELAYED_SAVE_TIMER = new Timer();
|
||||
private static final Timer DELAYED_SAVE_TIMER = TimerUtil.CreateTimer("DataSourceSaveTimer");
|
||||
/** How long a data source must remain un-modified before being written to disk. */
|
||||
private static final int SAVE_DELAY_IN_MS = 4_000;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.seibel.distanthorizons.core.util;
|
||||
|
||||
import java.util.Timer;
|
||||
|
||||
/**
|
||||
* Handles creating timers.
|
||||
* Used to prevent accidentally creating timers with the wrong format.
|
||||
*
|
||||
* @see ThreadUtil
|
||||
*/
|
||||
public class TimerUtil
|
||||
{
|
||||
|
||||
public static Timer CreateTimer(String timerName)
|
||||
{
|
||||
// isDaemon = true is necessary to allow MC to stop running even if the timer hasn't finished
|
||||
return new Timer(ThreadUtil.THREAD_NAME_PREFIX+timerName, true);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user