Add DhApi.isDhThread()
This commit is contained in:
@@ -52,7 +52,7 @@ public class DhApi
|
||||
{
|
||||
/**
|
||||
* If you can see this Java Doc, this can be ignored. <br>
|
||||
* This is just to you know that Javadocs are available and that you should use the API jar
|
||||
* This is just to let you know that Javadocs are available and that you should use the API jar
|
||||
* instead of the full mod jar. <br><br>
|
||||
*
|
||||
* Note: Don't use this string in your code. It may change and is only for reference.
|
||||
@@ -118,7 +118,11 @@ public class DhApi
|
||||
|
||||
|
||||
|
||||
//==================//
|
||||
// always available //
|
||||
//==================//
|
||||
|
||||
// interfaces //
|
||||
|
||||
/**
|
||||
* Used to bind/unbind Distant Horizons Api events.
|
||||
@@ -139,6 +143,8 @@ public class DhApi
|
||||
public static final IOverrideInjector<IDhApiOverrideable> overrides = OverrideInjector.INSTANCE;
|
||||
|
||||
|
||||
// getters //
|
||||
|
||||
/**
|
||||
* This version should only be updated when breaking changes are introduced to the Distant Horizons API.
|
||||
* @since API 1.0.0
|
||||
@@ -174,4 +180,13 @@ public class DhApi
|
||||
*/
|
||||
public static int getNetworkProtocolVersion() { return ModInfo.PROTOCOL_VERSION; }
|
||||
|
||||
|
||||
// methods //
|
||||
|
||||
/**
|
||||
* Returns true if the thread this method was called from is owned by Distant Horizons.
|
||||
* @since API 1.1.0
|
||||
*/
|
||||
public static boolean isDhThread() { return Thread.currentThread().getName().startsWith(ModInfo.THREAD_NAME_PREFIX); }
|
||||
|
||||
}
|
||||
|
||||
@@ -48,5 +48,7 @@ public final class ModInfo
|
||||
public static final String NETWORKING_RESOURCE_NAMESPACE = "distant_horizons";
|
||||
public static final String MULTIVERSE_PLUGIN_NAMESPACE = "world_control";
|
||||
|
||||
/** All DH owned threads should start with this string to allow for easier debugging and profiling. */
|
||||
public static String THREAD_NAME_PREFIX = "DH-";
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.util.threading.DhThreadFactory;
|
||||
import com.seibel.distanthorizons.core.util.threading.RateLimitedThreadPoolExecutor;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -38,8 +39,7 @@ public class ThreadUtil
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/** The prefix isn't strictly required, but makes debugging and profiling much easier. */
|
||||
public static String THREAD_NAME_PREFIX = "DH-";
|
||||
public static String THREAD_NAME_PREFIX = ModInfo.THREAD_NAME_PREFIX;
|
||||
|
||||
public static int MINIMUM_RELATIVE_PRIORITY = -4;
|
||||
public static int DEFAULT_RELATIVE_PRIORITY = 0;
|
||||
|
||||
Reference in New Issue
Block a user