void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, StateStackPtr& states) { wait_for_think_finished(); SearchTime = Time::now(); // As early as possible Signals.stopOnPonderhit = Signals.firstRootMove = false; Signals.stop = Signals.failedLowAtRoot = false; RootMoves.clear(); RootPos = pos; Limits = limits; if (states.get()) // If we don't set a new position, preserve current state { SetupStates = std::move(states); // Ownership transfer here assert(!states.get()); } for (const ExtMove& ms : MoveList<LEGAL>(pos)) if ( limits.searchmoves.empty() || std::count(limits.searchmoves.begin(), limits.searchmoves.end(), ms.move)) RootMoves.push_back(RootMove(ms.move)); main()->thinking = true; main()->notify_one(); // Starts main thread }
void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, StateStackPtr& states) { main()->join(); Signals.stopOnPonderhit = Signals.firstRootMove = false; Signals.stop = Signals.failedLowAtRoot = false; RootMoves.clear(); RootPos = pos; Limits = limits; if (states.get()) // If we don't set a new position, preserve current state { SetupStates = std::move(states); // Ownership transfer here assert(!states.get()); } for (const auto& m : MoveList<LEGAL>(pos)) if ( limits.searchmoves.empty() || std::count(limits.searchmoves.begin(), limits.searchmoves.end(), m)) RootMoves.push_back(RootMove(m)); main()->thinking = true; main()->notify_one(); // Wake up main thread: 'thinking' must be already set }