Fix deadlock in lstmtraing. (#3488)

This commit is contained in:
Tadahito Yao 2021-07-10 16:59:10 +09:00 committed by GitHub
parent 767fb5a177
commit 12e0fb4e01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -435,15 +435,17 @@ void DocumentData::LoadPageInBackground(int index) {
if (IsPageAvailable(index, &page)) {
return;
}
std::lock_guard<std::mutex> lock(pages_mutex_);
if (pages_offset_ == index) {
return;
{
std::lock_guard<std::mutex> lock(pages_mutex_);
if (pages_offset_ == index) {
return;
}
pages_offset_ = index;
for (auto page : pages_) {
delete page;
}
pages_.clear();
}
pages_offset_ = index;
for (auto page : pages_) {
delete page;
}
pages_.clear();
if (thread.joinable()) {
thread.join();
}