Detach search arguments from UI thread

Detach from the UI thread the input arguments used by
the search threads so that the UI thread is able to receive
and process any command sent by the GUI while other threads
keep searching.

With this patch there is no more need to block the UI
thread after a "stop", so it is a more reliable and
robust solution than the previous patch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2011-11-27 17:07:17 +01:00
parent 6809b57cfc
commit bb3427ca85
8 changed files with 45 additions and 59 deletions

View File

@@ -72,7 +72,6 @@ void uci_loop() {
quit = (token == "quit");
Search::Signals.stop = true;
Threads[0].wake_up(); // In case is waiting for stop or ponderhit
Threads.wait_end_of_search(); // Block here until search finishes
}
else if (cmd == "ponderhit")
@@ -206,18 +205,16 @@ namespace {
void go(Position& pos, istringstream& is) {
string token;
Search::LimitsType limits;
std::vector<Move> searchMoves;
int time[] = { 0, 0 }, inc[] = { 0, 0 };
memset(&Search::Limits, 0, sizeof(Search::Limits));
Search::RootMoves.clear();
Search::RootPosition = &pos;
while (is >> token)
{
if (token == "infinite")
Search::Limits.infinite = true;
limits.infinite = true;
else if (token == "ponder")
Search::Limits.ponder = true;
limits.ponder = true;
else if (token == "wtime")
is >> time[WHITE];
else if (token == "btime")
@@ -227,23 +224,22 @@ namespace {
else if (token == "binc")
is >> inc[BLACK];
else if (token == "movestogo")
is >> Search::Limits.movesToGo;
is >> limits.movesToGo;
else if (token == "depth")
is >> Search::Limits.maxDepth;
is >> limits.maxDepth;
else if (token == "nodes")
is >> Search::Limits.maxNodes;
is >> limits.maxNodes;
else if (token == "movetime")
is >> Search::Limits.maxTime;
is >> limits.maxTime;
else if (token == "searchmoves")
while (is >> token)
Search::RootMoves.push_back(move_from_uci(pos, token));
searchMoves.push_back(move_from_uci(pos, token));
}
searchMoves.push_back(MOVE_NONE);
limits.time = time[pos.side_to_move()];
limits.increment = inc[pos.side_to_move()];
Search::RootMoves.push_back(MOVE_NONE);
Search::Limits.time = time[pos.side_to_move()];
Search::Limits.increment = inc[pos.side_to_move()];
Threads.start_thinking();
Threads.start_thinking(pos, limits, searchMoves, true);
}