Dynamic thread count

This commit is contained in:
Sotr
2019-03-28 15:46:20 +08:00
parent f9eb7d8a60
commit ae97996ace
3 changed files with 9 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
public class AkarinAsyncExecutor {
private static final ExecutorService singleExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("Akarin Single Async Executor Thread - %1$d").build());
private static final ExecutorService asyncExecutor = Executors.newFixedThreadPool(4, new ThreadFactoryBuilder().setNameFormat("Akarin Async Executor Thread - %1$d").build());
private static final ExecutorService asyncExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() / 4, new ThreadFactoryBuilder().setNameFormat("Akarin Async Executor Thread - %1$d").build());
/**
* Posts a task to be executed asynchronously in a single thread

View File

@@ -96,6 +96,8 @@ public class AkarinUserCache {
PropertyMap offlineProperties = offlineProfile.getProperties();
for (Property property : gameprofile.getProperties().get("textures"))
offlineProperties.put("textures", property);
callback.onProfileLookupSucceeded(offlineProfile);
}
@Override
@@ -107,7 +109,11 @@ public class AkarinUserCache {
profileRepo.findProfilesByNames(new String[] { keyUsername }, Agent.MINECRAFT, skinHandler);
};
AkarinAsyncExecutor.scheduleAsyncTask(lookupTextures);
if (async)
AkarinAsyncExecutor.scheduleAsyncTask(lookupTextures);
else
lookupTextures.run();
} else {
callback.onProfileLookupSucceeded(offlineProfile);
}
}