fix restarting stockfish

This commit is contained in:
jusax23 2023-11-19 20:46:07 +01:00
parent a7e7cb4bfc
commit 5c1c4e8980
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
4 changed files with 12 additions and 9 deletions

View file

@ -27,14 +27,6 @@ final DynamicLibrary _dylib = () {
if (Platform.isWindows) {
return DynamicLibrary.open('$_libName.dll');
}
/*if (Platform.isLinux) {
return DynamicLibrary.open(
'${File(Platform.resolvedExecutable).parent.parent.path}/plugins/flutter_stockfish_plugin/shared/lib$_libName.so');
}
if (Platform.isWindows) {
return DynamicLibrary.open(
'${File(Platform.resolvedExecutable).parent.parent.parent.path}/plugins/flutter_stockfish_plugin/shared/$_releaseType/$_libName.dll');
}*/
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
}();

View file

@ -23,7 +23,8 @@ const char *QUITOK = "quitok\n";
int main(int, char **);
int stockfish_init() {
//std::cout << "Init Stockfish: Nothing todo!";
fakein.open();
fakeout.open();
return 0;
}

View file

@ -8,9 +8,18 @@ bool FakeStream::try_get_line(std::string& val) {
return true;
}
void FakeStream::open() {
std::lock_guard<std::mutex> lock(mutex_guard);
closed = false;
mutex_signal.notify_one();
}
void FakeStream::close() {
std::lock_guard<std::mutex> lock(mutex_guard);
closed = true;
while (!string_queue.empty()) {
string_queue.pop();
}
mutex_signal.notify_one();
}
bool FakeStream::is_closed() { return closed; }

View file

@ -37,6 +37,7 @@ class FakeStream {
bool try_get_line(std::string& val);
void open();
void close();
bool is_closed();