mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-22 09:39:45 +00:00
Allow users to customize the size of thread pools. (#86)
* Increase compatible Java version to 8. * Support Forge & Fabric 1.15.2 * Fix lag spike while loading player skull textures. * Allow users to customize the size of thread pools. * Use the old scheme about loading skulls to avoid blocking the thread pool when "enableUpdateSkull" is true. * Fix merge.
This commit is contained in:
1 parent
8b1400ef0d
commit
a9f19cfc8d
3 files changed
+12
-13
No files matched your search
@@ -2,8 +2,7 @@ package customskinloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -55,7 +54,7 @@ public class CustomSkinLoader {
|
||||
private static final ProfileCache profileCache=new ProfileCache();
|
||||
private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager();
|
||||
|
||||
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(3, 33, 3, TimeUnit.MINUTES, new LinkedBlockingDeque<>(333), Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy());
|
||||
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||
|
||||
//For User Skin
|
||||
public static Map<Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile){
|
||||
@@ -168,12 +167,17 @@ public class CustomSkinLoader {
|
||||
}
|
||||
if (!profileCache.isLoading(credential)) {
|
||||
profileCache.setLoading(credential, true);
|
||||
threadPool.execute(() -> {
|
||||
Runnable loadThread = () -> {
|
||||
String tempName = Thread.currentThread().getName();
|
||||
Thread.currentThread().setName(username + "'s skull");
|
||||
loadProfile0(gameProfile);//Load in thread
|
||||
Thread.currentThread().setName(tempName);
|
||||
});
|
||||
};
|
||||
if (config.enableUpdateSkull) {
|
||||
new Thread(loadThread).start();
|
||||
} else {
|
||||
threadPool.execute(loadThread);
|
||||
}
|
||||
}
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
@@ -185,8 +189,4 @@ public class CustomSkinLoader {
|
||||
logger.info("Minecraft: "+MinecraftUtil.getMinecraftMainVersion()+"("+MinecraftUtil.getMinecraftVersionText()+")");
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static void initStatic(){
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user