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:
Marco Costalba
2011-11-05 07:53:19 +01:00
parent 22b9307aba
commit 2617aa415e
4 changed files with 188 additions and 65 deletions

View File

@@ -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;