Allow Bitbases::init() to be called more than once

Currently if we call it more than once, we crash.

This is not a real problem, because this function is
indeed called just once. Nevertheless with this small fix,
that gets rid of a hidden 'static' variable, we cleanly
resolve the issue.

While there, fix also ThreadPool::exit to return in a
consistent state. Now all the init() functions but
UCI::init() are reentrant and can be called multiple
times.

No functional change.
This commit is contained in:
Marco Costalba
2015-03-22 12:41:11 +01:00
parent 35a082064f
commit dc3a5f791e
2 changed files with 5 additions and 1 deletions

View File

@@ -299,9 +299,12 @@ void ThreadPool::init() {
void ThreadPool::exit() {
delete_thread(timer); // As first because check_time() accesses threads data
timer = nullptr;
for (Thread* th : *this)
delete_thread(th);
clear(); // Get rid of stale pointers
}