Skip to content

Commit

Permalink
Send most commands immediately for fear of possible hang-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Jun 5, 2018
1 parent 69dedf4 commit 526c9f7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,19 @@ public void sendCommand(String command) {
* Sends a command from command queue for leelaz to execute if it is ready
*/
private void trySendCommandFromQueue() {
if (!isResponseUpToDate()) {
return; // leelaz is not ready yet
}
// Defer sending "lz-analyze" if leelaz is not ready yet.
// Though all commands should be deferred theoretically,
// only "lz-analyze" is differed here for fear of
// possible hang-up by missing response for some reason.
// cmdQueue can be replaced with a mere String variable in this case,
// but it is kept for future change of our mind.
synchronized(cmdQueue) {
String command = cmdQueue.pollFirst();
if (command != null) {
sendCommandToLeelaz(command);
String command = cmdQueue.peekFirst();
if (command == null || (command.startsWith("lz-analyze") && !isResponseUpToDate())) {
return;
}
cmdQueue.removeFirst();
sendCommandToLeelaz(command);
}
}

Expand Down

0 comments on commit 526c9f7

Please sign in to comment.