Changed async execution setup.
Two beta threads with lower thread priority and one alpha with normal thread priority. Implemented use of both in chunk loading.
This commit is contained in:
@@ -11,7 +11,8 @@ import ca.recrown.islandsurvivalcraft.datatypes.Point2;
|
||||
|
||||
public class Utilities {
|
||||
public final static int CHUNK_SIZE = 16;
|
||||
public final static ExecutorService ISC_EXECUTOR = Executors.newFixedThreadPool(2, createThreadFactory());
|
||||
public final static ExecutorService ISC_EXECUTOR_ALPHA = Executors.newFixedThreadPool(1, createThreadFactory("ALPHA", Thread.NORM_PRIORITY));
|
||||
public final static ExecutorService ISC_EXECUTOR_BETA = Executors.newFixedThreadPool(2, createThreadFactory("BETA", Thread.MIN_PRIORITY));
|
||||
|
||||
public static <K, V> HashMap<V, ArrayList<K>> invertHashMap(HashMap<K, V> hashMap) {
|
||||
HashMap<V, ArrayList<K>> res = new HashMap<>();
|
||||
@@ -76,11 +77,12 @@ public class Utilities {
|
||||
return worldToLocalChunkCoordinates(worldCoordinates.x, worldCoordinates.y);
|
||||
}
|
||||
|
||||
public static ThreadFactory createThreadFactory() {
|
||||
return new ThreadFactory(){
|
||||
public static ThreadFactory createThreadFactory(final String identifier, final int priority) {
|
||||
return new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread thread = new Thread(r, "ISC-worker");
|
||||
Thread thread = new Thread(r, String.format("ISC-worker-%s", identifier));
|
||||
thread.setPriority(priority);
|
||||
return thread;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user