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; return ret;
} }
// FIXME!! Writes should be handled by separate thread.
/** @inheritDoc */ /** @inheritDoc */
@Override @Override
public void writeLineToEngine(String data) { public void writeLineToEngine(String data) {

View File

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

View File

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