mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Improve timeout tracking for expressions
This commit is contained in:
parent
91a78f725a
commit
b0528f157a
@ -37,6 +37,7 @@ import java.lang.invoke.MethodHandle;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -141,6 +142,7 @@ public class Expression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double evaluateRootTimed(int timeout) throws EvaluationException {
|
private double evaluateRootTimed(int timeout) throws EvaluationException {
|
||||||
|
CountDownLatch startLatch = new CountDownLatch(1);
|
||||||
Request request = Request.request();
|
Request request = Request.request();
|
||||||
Future<Double> result = evalThread.submit(() -> {
|
Future<Double> result = evalThread.submit(() -> {
|
||||||
Request local = Request.request();
|
Request local = Request.request();
|
||||||
@ -148,12 +150,14 @@ public class Expression {
|
|||||||
local.setWorld(request.getWorld());
|
local.setWorld(request.getWorld());
|
||||||
local.setEditSession(request.getEditSession());
|
local.setEditSession(request.getEditSession());
|
||||||
try {
|
try {
|
||||||
|
startLatch.countDown();
|
||||||
return Expression.this.evaluateRoot();
|
return Expression.this.evaluateRoot();
|
||||||
} finally {
|
} finally {
|
||||||
Request.reset();
|
Request.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
startLatch.await();
|
||||||
return result.get(timeout, TimeUnit.MILLISECONDS);
|
return result.get(timeout, TimeUnit.MILLISECONDS);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
|
@ -2,4 +2,4 @@ junit.jupiter.execution.parallel.enabled=true
|
|||||||
junit.jupiter.execution.parallel.mode.default=concurrent
|
junit.jupiter.execution.parallel.mode.default=concurrent
|
||||||
junit.jupiter.execution.parallel.mode.classes.default=same_thread
|
junit.jupiter.execution.parallel.mode.classes.default=same_thread
|
||||||
junit.jupiter.execution.parallel.config.strategy=dynamic
|
junit.jupiter.execution.parallel.config.strategy=dynamic
|
||||||
junit.jupiter.execution.parallel.config.dynamic.factor=4
|
junit.jupiter.execution.parallel.config.dynamic.factor=1
|
||||||
|
Loading…
Reference in New Issue
Block a user