Add 'usenormalthreadpriority' setting (makes renders on Windows use normal priority)

This commit is contained in:
Mike Primm 2011-12-15 00:33:40 +08:00 committed by mikeprimm
parent f7dedff413
commit 03b280fe2d
3 changed files with 18 additions and 4 deletions

View File

@ -17,14 +17,16 @@ public class AsynchronousQueue<T> {
private int accelDequeueThresh;
private int pendingcnt;
private int pendinglimit;
private boolean normalprio;
public AsynchronousQueue(Handler<T> handler, int dequeueTime, int accelDequeueThresh, int accelDequeueTime, int pendinglimit) {
public AsynchronousQueue(Handler<T> handler, int dequeueTime, int accelDequeueThresh, int accelDequeueTime, int pendinglimit, boolean normalprio) {
this.handler = handler;
this.dequeueTime = dequeueTime;
this.accelDequeueTime = accelDequeueTime;
this.accelDequeueThresh = accelDequeueThresh;
if(pendinglimit < 1) pendinglimit = 1;
this.pendinglimit = pendinglimit;
this.normalprio = normalprio;
}
public boolean push(T t) {
@ -83,7 +85,8 @@ public class AsynchronousQueue<T> {
});
thread.start();
try {
thread.setPriority(Thread.MIN_PRIORITY);
if(!normalprio)
thread.setPriority(Thread.MIN_PRIORITY);
} catch (SecurityException e) {
Log.info("Failed to set minimum priority for worker thread!");
}

View File

@ -50,6 +50,7 @@ public class MapManager {
private int progressinterval = 100;
private boolean saverestorepending = true;
private boolean hideores = false;
private boolean usenormalpriority = false;
private boolean pauseupdaterenders = false;
private boolean pausefullrenders = false;
@ -117,7 +118,8 @@ public class MapManager {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
t.setPriority(Thread.MIN_PRIORITY);
if(!mapman.usenormalpriority)
t.setPriority(Thread.MIN_PRIORITY);
t.setName("Dynmap Render Thread");
return t;
}
@ -658,6 +660,9 @@ public class MapManager {
/* Get block hiding data, if any */
hideores = configuration.getBoolean("hideores", false);
/* See what priority to use */
usenormalpriority = configuration.getBoolean("usenormalthreadpriority", false);
/* Clear color scheme */
ColorScheme.reset();
@ -684,7 +689,8 @@ public class MapManager {
(int) (configuration.getDouble("renderinterval", 0.5) * 1000),
configuration.getInteger("renderacceleratethreshold", 30),
(int)(configuration.getDouble("renderaccelerateinterval", 0.2) * 1000),
configuration.getInteger("tiles-rendered-at-once", (Runtime.getRuntime().availableProcessors()+1)/2));
configuration.getInteger("tiles-rendered-at-once", (Runtime.getRuntime().availableProcessors()+1)/2),
usenormalpriority);
/* On dedicated thread, so default to no delays */
timeslice_int = (long)(configuration.getDouble("timesliceinterval", 0.0) * 1000);

View File

@ -133,6 +133,11 @@ renderaccelerateinterval: 0.2
# How many update tiles to work on at once (if not defined, default is 1/2 the number of cores)
tiles-rendered-at-once: 2
# If true, use normal priority threads for rendering (versus low priority) - this can keep rendering
# from starving on busy Windows boxes (Linux JVMs pretty much ignore thread priority), but may result
# in more competition for CPU resources with other processes
usenormalthreadpriority: true
# Save and restore pending tile renders - prevents their loss on server shutdown or /reload
saverestorepending: true