Improved check in garbage collection
This commit is contained in:
parent
ffaed1581a
commit
b6ba834669
1 changed files with 8 additions and 4 deletions
|
|
@ -694,11 +694,15 @@ void sfz::FilePool::triggerGarbageCollection() noexcept
|
||||||
|
|
||||||
// do garbage collection when changing the status is success
|
// do garbage collection when changing the status is success
|
||||||
if (data.status.compare_exchange_strong(status, FileData::Status::GarbageCollecting)) {
|
if (data.status.compare_exchange_strong(status, FileData::Status::GarbageCollecting)) {
|
||||||
|
// recheck readerCount
|
||||||
|
auto readerCount = data.readerCount.load();
|
||||||
|
if (readerCount == 0) {
|
||||||
data.availableFrames = 0;
|
data.availableFrames = 0;
|
||||||
garbageToCollect.push_back(std::move(data.fileData));
|
garbageToCollect.push_back(std::move(data.fileData));
|
||||||
data.status = FileData::Status::Preloaded;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
data.status = status;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue