}
-// d'tor cleanly terminates the threads when the program exits.
+// exit() cleanly terminates the threads before the program exits.
-ThreadPool::~ThreadPool() {
+void ThreadPool::exit() {
for (size_t i = 0; i < threads.size(); i++)
delete threads[i];
// a new search, then returns immediately.
void ThreadPool::start_searching(const Position& pos, const LimitsType& limits,
- const std::vector<Move>& searchMoves) {
+ const std::vector<Move>& searchMoves, StateStackPtr& states) {
wait_for_search_finished();
- SearchTime.restart(); // As early as possible
+ SearchTime = Time::current_time(); // As early as possible
Signals.stopOnPonderhit = Signals.firstRootMove = false;
Signals.stop = Signals.failedLowAtRoot = false;
RootPosition = pos;
Limits = limits;
+ SetupStates = states; // Ownership transfer here
RootMoves.clear();
for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)