1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-11 18:00:29 +00:00

Bump the priority of the computer thread

As this is responsible for interrupting computers, we should make sure
its priority is higher than the background threads. It spends most of
its time sleeping, so should be fine.
This commit is contained in:
Jonathan Coates 2023-09-05 18:39:55 +01:00
parent 07113c3e9b
commit 4e82bd352d
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -54,7 +54,15 @@ import java.util.concurrent.locks.ReentrantLock;
@SuppressWarnings("GuardedBy") // FIXME: Hard to know what the correct thing to do is.
public final class ComputerThread {
private static final Logger LOG = LoggerFactory.getLogger(ComputerThread.class);
private static final ThreadFactory monitorFactory = ThreadUtils.factory("Computer-Monitor");
/**
* A factory for the monitor thread. We want this a slightly higher priority than normal to ensure that the computer
* thread is interrupted. This spends most of it its time idle, so should be safe.
*/
private static final ThreadFactory monitorFactory = ThreadUtils.builder("Computer-Monitor")
.setPriority((Thread.NORM_PRIORITY + Thread.MAX_PRIORITY) / 2)
.build();
private static final ThreadFactory workerFactory = ThreadUtils.lowPriorityFactory("Computer-Worker");
/**