fix restarting stockfish
This commit is contained in:
parent
a7e7cb4bfc
commit
5c1c4e8980
4 changed files with 12 additions and 9 deletions
|
@ -27,14 +27,6 @@ final DynamicLibrary _dylib = () {
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
return DynamicLibrary.open('$_libName.dll');
|
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}');
|
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ const char *QUITOK = "quitok\n";
|
||||||
int main(int, char **);
|
int main(int, char **);
|
||||||
|
|
||||||
int stockfish_init() {
|
int stockfish_init() {
|
||||||
//std::cout << "Init Stockfish: Nothing todo!";
|
fakein.open();
|
||||||
|
fakeout.open();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,18 @@ bool FakeStream::try_get_line(std::string& val) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeStream::open() {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex_guard);
|
||||||
|
closed = false;
|
||||||
|
mutex_signal.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
void FakeStream::close() {
|
void FakeStream::close() {
|
||||||
std::lock_guard<std::mutex> lock(mutex_guard);
|
std::lock_guard<std::mutex> lock(mutex_guard);
|
||||||
closed = true;
|
closed = true;
|
||||||
|
while (!string_queue.empty()) {
|
||||||
|
string_queue.pop();
|
||||||
|
}
|
||||||
mutex_signal.notify_one();
|
mutex_signal.notify_one();
|
||||||
}
|
}
|
||||||
bool FakeStream::is_closed() { return closed; }
|
bool FakeStream::is_closed() { return closed; }
|
||||||
|
|
|
@ -37,6 +37,7 @@ class FakeStream {
|
||||||
|
|
||||||
bool try_get_line(std::string& val);
|
bool try_get_line(std::string& val);
|
||||||
|
|
||||||
|
void open();
|
||||||
void close();
|
void close();
|
||||||
bool is_closed();
|
bool is_closed();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue