mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-20 04:35:32 +00:00
fixing TestAbortingHeavyLoadQuery for good
This commit is contained in:
+1
-1
@@ -83,7 +83,7 @@ public class TestAbortingHeavyLoadQuery {
|
||||
/** The time a step of a heavy load instruction blocks the executing thread (using {@link Thread#sleep(long)}). */
|
||||
private static final long HeavyLoadInstructionStepDuration = 50;
|
||||
/** The number of steps a heavy load instruction performs */
|
||||
private static final int HeavyLoadInstructionNumberOfSteps = 100;
|
||||
private static final int HeavyLoadInstructionNumberOfSteps = 10;
|
||||
/** The total time a heavy load instruction blocks the executing thread (using {@link Thread#sleep(long)}). */
|
||||
private static final long HeavyLoadInstructionTotalDuration = HeavyLoadInstructionStepDuration * HeavyLoadInstructionNumberOfSteps;
|
||||
|
||||
|
||||
+10
-6
@@ -30,18 +30,22 @@ public class StatefulBlockingInstruction<ResultType> extends StatefulProcessorIn
|
||||
protected ResultType internalComputeResult() throws Exception {
|
||||
if (getTotalBlockDuration() > 0) {
|
||||
actionBeforeBlock();
|
||||
for (int i = 0; i < numberOfSteps; i++) {
|
||||
if (isAborted()) {
|
||||
actionBeforeAbort();
|
||||
computeResultWasAborted = true;
|
||||
break;
|
||||
}
|
||||
for (int i = 0; !checkIsAborted() && i < numberOfSteps; i++) {
|
||||
Thread.sleep(stepDuration);
|
||||
}
|
||||
actionAfterBlock();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean checkIsAborted() {
|
||||
final boolean result = isAborted();
|
||||
if (result) {
|
||||
actionBeforeAbort();
|
||||
computeResultWasAborted = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void actionBeforeBlock() { }
|
||||
protected void actionBeforeAbort() { }
|
||||
|
||||
Reference in New Issue
Block a user