Skip to content
Permalink
Browse files

Improve timeout tracking for expressions

  • Loading branch information
octylFractal committed Oct 26, 2019
1 parent 91a78f7 commit b0528f157aaddc71474b9c23e006e6eba760df58
@@ -37,6 +37,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Stack;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -141,19 +142,22 @@ public double evaluate(double[] values, int timeout) throws EvaluationException
}

private double evaluateRootTimed(int timeout) throws EvaluationException {
CountDownLatch startLatch = new CountDownLatch(1);
Request request = Request.request();
Future<Double> result = evalThread.submit(() -> {
Request local = Request.request();
local.setSession(request.getSession());
local.setWorld(request.getWorld());
local.setEditSession(request.getEditSession());
try {
startLatch.countDown();
return Expression.this.evaluateRoot();
} finally {
Request.reset();
}
});
try {
startLatch.await();
return result.get(timeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
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.classes.default=same_thread
junit.jupiter.execution.parallel.config.strategy=dynamic
junit.jupiter.execution.parallel.config.dynamic.factor=4
junit.jupiter.execution.parallel.config.dynamic.factor=1

0 comments on commit b0528f1

Please sign in to comment.
You can’t perform that action at this time.