Upon clearing the file pool, clear the last used files and garbage queue
I also added an early exit with an assertion to catch unintended behavior
This commit is contained in:
parent
a372d40c48
commit
1d2c3a4244
1 changed files with 12 additions and 1 deletions
|
|
@ -435,7 +435,10 @@ void sfz::FilePool::loadingJob(QueuedFileData data) noexcept
|
||||||
|
|
||||||
void sfz::FilePool::clear()
|
void sfz::FilePool::clear()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<SpinMutex> guard { garbageAndLastUsedMutex };
|
||||||
emptyFileLoadingQueues();
|
emptyFileLoadingQueues();
|
||||||
|
garbageToCollect.clear();
|
||||||
|
lastUsedFiles.clear();
|
||||||
preloadedFiles.clear();
|
preloadedFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -593,7 +596,15 @@ void sfz::FilePool::triggerGarbageCollection() noexcept
|
||||||
if (garbageToCollect.size() == garbageToCollect.capacity())
|
if (garbageToCollect.size() == garbageToCollect.capacity())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto& data = preloadedFiles[id];
|
auto it = preloadedFiles.find(id);
|
||||||
|
if (it == preloadedFiles.end()) {
|
||||||
|
// Getting here means that the preloadedFiles got changed (probably cleared)
|
||||||
|
// while the lastUsedFiles were untouched.
|
||||||
|
ASSERTFALSE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfz::FileData& data = it->second;
|
||||||
if (data.status == FileData::Status::Preloaded)
|
if (data.status == FileData::Status::Preloaded)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue