Change priorities a bit
This commit is contained in:
+15
-3
@@ -36,7 +36,7 @@ public class PriorityTaskPicker
|
||||
|
||||
/**
|
||||
* Creates an executor with a specific priority.
|
||||
* Higher priority executors have more entries in the distribution queue, giving them a greater chance to run tasks.
|
||||
* Higher priority executors have more exponentially entries in the distribution queue, giving them a greater chance to run tasks.
|
||||
*
|
||||
* @param priority the priority level of the executor
|
||||
* @return a newly created Executor
|
||||
@@ -45,7 +45,7 @@ public class PriorityTaskPicker
|
||||
{
|
||||
Executor executor = new Executor();
|
||||
|
||||
int entriesToAdd = priority + 1;
|
||||
int entriesToAdd = 1 << priority;
|
||||
int gapBetweenEntries = (int) (1 / (double) entriesToAdd * this.executorQueue.size());
|
||||
|
||||
// Distribute the executor's entries in the queue, ensuring fair distribution
|
||||
@@ -135,7 +135,19 @@ public class PriorityTaskPicker
|
||||
public void shutdown()
|
||||
{
|
||||
this.isShutDown = true;
|
||||
this.threadPoolExecutor.shutdown();
|
||||
|
||||
try
|
||||
{
|
||||
this.threadPoolExecutor.shutdown();
|
||||
if (!this.threadPoolExecutor.awaitTermination(5, TimeUnit.SECONDS))
|
||||
{
|
||||
this.threadPoolExecutor.shutdownNow();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-5
@@ -91,15 +91,15 @@ public class ThreadPoolUtil
|
||||
taskPicker = new PriorityTaskPicker();
|
||||
|
||||
// IO should never be stuck waiting for something else to complete
|
||||
networkCompressionThreadPool = taskPicker.createExecutor(3);
|
||||
fileHandlerThreadPool = taskPicker.createExecutor(3);
|
||||
networkCompressionThreadPool = taskPicker.createExecutor(4);
|
||||
fileHandlerThreadPool = taskPicker.createExecutor(4);
|
||||
|
||||
// Normal priority tasks
|
||||
chunkToLodBuilderThreadPool = taskPicker.createExecutor(2);
|
||||
chunkToLodBuilderThreadPool = taskPicker.createExecutor(3);
|
||||
updatePropagatorThreadPool = taskPicker.createExecutor(2);
|
||||
|
||||
// World gen tasks are heavy and nothing strictly depends on them, so it may wait a bit
|
||||
worldGenThreadPool = taskPicker.createExecutor(1);
|
||||
// World gen tasks are heavy and nothing strictly depends on them, so they may wait a bit
|
||||
worldGenThreadPool = taskPicker.createExecutor(0);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user