Limit expression thread count to processor count.

This commit is contained in:
Kenzie Togami 2019-10-26 16:44:23 -07:00
parent b0528f157a
commit fa42e40281
No known key found for this signature in database
GPG Key ID: 5D200B325E157A81

View File

@ -74,11 +74,12 @@ import java.util.concurrent.TimeoutException;
public class Expression { public class Expression {
private static final ThreadLocal<Stack<Expression>> instance = new ThreadLocal<>(); private static final ThreadLocal<Stack<Expression>> instance = new ThreadLocal<>();
private static final ExecutorService evalThread = Executors.newCachedThreadPool( private static final ExecutorService evalThread = Executors.newFixedThreadPool(
new ThreadFactoryBuilder() Runtime.getRuntime().availableProcessors(),
.setDaemon(true) new ThreadFactoryBuilder()
.setNameFormat("worldedit-expression-eval-%d") .setDaemon(true)
.build()); .setNameFormat("worldedit-expression-eval-%d")
.build());
private final SlotTable slots = new SlotTable(); private final SlotTable slots = new SlotTable();
private final List<String> providedSlots; private final List<String> providedSlots;