Skip to content

Commit

Permalink
[feat] check interrupts increasingly (till ~ previous 30k)
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Dec 3, 2020
1 parent 70ee48f commit 35ddadc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/org/joni/ByteCodeMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
import org.joni.exception.InternalException;

class ByteCodeMachine extends StackMachine {
private static final int INTERRUPT_CHECK_EVERY = 30000;
private static final int MAX_INTERRUPT_CHECK_EVERY = 256 << 7; // 32768
int INTERRUPT_CHECK_EVERY = 256; // << 1 after each check up to ^^^
volatile boolean interrupted = false;

private int bestLen; // return value
Expand Down Expand Up @@ -444,6 +445,7 @@ private void handleInterrupted(final boolean checkThreadInterrupt) throws Interr
Thread.currentThread().interrupted();
throw new InterruptedException();
}
INTERRUPT_CHECK_EVERY = Math.min(INTERRUPT_CHECK_EVERY << 1, MAX_INTERRUPT_CHECK_EVERY);
}

private boolean opEnd() {
Expand Down

0 comments on commit 35ddadc

Please sign in to comment.