Skip to content

Commit

Permalink
Improved check in garbage collection
Browse files Browse the repository at this point in the history
  • Loading branch information
KKQ-KKQ committed Feb 16, 2024
1 parent d7f1d81 commit 795fe2e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/sfizz/FilePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,14 @@ void sfz::FilePool::triggerGarbageCollection() noexcept

// do garbage collection when changing the status is success
if (data.status.compare_exchange_strong(status, FileData::Status::GarbageCollecting)) {
data.availableFrames = 0;
garbageToCollect.push_back(std::move(data.fileData));
data.status = FileData::Status::Preloaded;
return true;
// recheck readerCount
auto readerCount = data.readerCount.load();
if (readerCount == 0) {
data.availableFrames = 0;
garbageToCollect.push_back(std::move(data.fileData));
return true;
}
data.status = status;
}
return false;
});
Expand Down

0 comments on commit 795fe2e

Please sign in to comment.