DroidFish: Don't do network communication on main thread.

This commit is contained in:
Peter Osterlund 2017-04-22 09:22:39 +02:00
parent b8aaa215d3
commit 9480603ddb
3 changed files with 2 additions and 6 deletions

View File

@ -264,6 +264,7 @@ public class ExternalEngine extends UCIEngineBase {
return ret;
}
// FIXME!! Writes should be handled by separate thread.
/** @inheritDoc */
@Override
public void writeLineToEngine(String data) {

View File

@ -158,7 +158,6 @@ public class NetworkEngine extends UCIEngineBase {
else
report.reportError(context.getString(R.string.engine_terminated));
}
try { socket.close(); } catch (IOException e) {}
}
engineToGui.close();
}
@ -189,6 +188,7 @@ public class NetworkEngine extends UCIEngineBase {
report.reportError(context.getString(R.string.engine_terminated));
}
isRunning = false;
try { socket.getOutputStream().write("quit\n".getBytes()); } catch (IOException e) {}
try { socket.close(); } catch (IOException ex) {}
}
}
@ -267,10 +267,6 @@ public class NetworkEngine extends UCIEngineBase {
isRunning = false;
if (startupThread != null)
startupThread.interrupt();
if (socket != null) {
try { socket.getOutputStream().write("quit\n".getBytes()); } catch (IOException e) {}
try { socket.close(); } catch (IOException e) {}
}
super.shutDown();
if (stdOutThread != null)
stdOutThread.interrupt();

View File

@ -64,7 +64,6 @@ public interface UCIEngine {
*/
String readLineFromEngine(int timeoutMillis);
// FIXME!! Writes should be handled by separate thread.
/** Write a line to the engine. \n will be added automatically. */
void writeLineToEngine(String data);