Skip to content

Commit

Permalink
Merge pull request #36 from sauce-code/sonar-cube-bugfixes
Browse files Browse the repository at this point in the history
Sonar cube bugfixes
  • Loading branch information
sauce-code authored Feb 7, 2025
2 parents 339c326 + 2ac8911 commit 732cc36
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cuckoo-uci/src/main/java/org/petero/cuckoo/uci/EngineControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public final void ponderHit() {
}
infinite = (maxTimeLimit < 0) && (maxDepth < 0) && (maxNodes < 0);
ponder = false;
synchronized (threadMutex) {
threadMutex.notifyAll();
}
}

public final void stopSearch() {
Expand Down Expand Up @@ -248,14 +251,17 @@ private void startThread(final int minTimeLimit, final int maxTimeLimit, int max
if (m == null) {
m = sc.iterativeDeepening(srchMoves, srchmaxDepth, maxNodes, false);
}
while (ponder || infinite) {

// We should not respond until told to do so. Just wait
// until
// we are allowed to respond.
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
break;
synchronized (threadMutex) {
while (ponder || infinite) {
try {
threadMutex.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
Move ponderMove = getPonderMove(pos, m);
Expand Down

0 comments on commit 732cc36

Please sign in to comment.