Fix some races and clarify the code

Better split code that should be run at
startup from code run at ucinewgame. Also
fix several races when 'bench', 'perft' and
'ucinewgame' are sent just after 'bestomve'
from the engine threads are still running.

Also use a specific UI thread instead of
main thread when setting up the Position
object used by UI uci loop. This fixes a
race when sending 'eval' command while searching.

We accept a race on 'setoption' to allow the
GUI to change an option while engine is searching
withouth stalling the pipe. Note that changing an
option while searchingg is anyhow not mandated by
UCI protocol.

No functional change.
This commit is contained in:
Marco Costalba
2017-08-06 04:43:02 -07:00
parent dbc984d9f8
commit 750dfa0521
4 changed files with 14 additions and 16 deletions

View File

@@ -24,6 +24,7 @@
#include "position.h"
#include "search.h"
#include "thread.h"
#include "tt.h"
#include "uci.h"
#include "syzygy/tbprobe.h"
@@ -42,7 +43,10 @@ int main(int argc, char* argv[]) {
Bitbases::init();
Search::init();
Pawns::init();
Tablebases::init(Options["SyzygyPath"]);
TT.resize(Options["Hash"]);
Threads.init();
Search::clear(); // After threads are up
UCI::loop(argc, argv);