mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 17:12:40 +01:00
DroidFish: Don't do network communication on main thread.
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user