mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Rewrite how commands from GUI are read
Instead of polling for input use a dedicated listener thread to read commands from the GUI independently from other threads. To do this properly we have to delegate to the listener all the reading from the GUI: while searching but also while waiting for a command, like in std::getline(). So we have two possible behaviours: in-sync mode, in which the thread mimics std::getline() and the caller blocks until something is read from GUI, and async mode where the listener continuously reads and processes GUI commands while other threads are searching. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "move.h"
|
||||
#include "position.h"
|
||||
#include "search.h"
|
||||
#include "thread.h"
|
||||
#include "ucioption.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -60,8 +61,10 @@ void uci_loop() {
|
||||
string cmd, token;
|
||||
bool quit = false;
|
||||
|
||||
while (!quit && getline(cin, cmd))
|
||||
while (!quit)
|
||||
{
|
||||
Threads.getline(cmd);
|
||||
|
||||
istringstream is(cmd);
|
||||
|
||||
is >> skipws >> token;
|
||||
|
||||
Reference in New Issue
Block a user