Protect the access of thread flags under semaphore
This commit is contained in:
parent
04fabd46d0
commit
fcfcd5b8cc
1 changed files with 6 additions and 11 deletions
|
|
@ -464,9 +464,7 @@ bool is_ready(std::future<R> const& f)
|
||||||
void sfz::FilePool::dispatchingJob() noexcept
|
void sfz::FilePool::dispatchingJob() noexcept
|
||||||
{
|
{
|
||||||
QueuedFileData queuedData;
|
QueuedFileData queuedData;
|
||||||
while (dispatchFlag) {
|
while (dispatchBarrier.wait(), dispatchFlag) {
|
||||||
dispatchBarrier.wait();
|
|
||||||
|
|
||||||
if (emptyQueueFlag) {
|
if (emptyQueueFlag) {
|
||||||
while (filesToLoad.try_pop(queuedData)) {
|
while (filesToLoad.try_pop(queuedData)) {
|
||||||
// pass
|
// pass
|
||||||
|
|
@ -492,15 +490,12 @@ void sfz::FilePool::dispatchingJob() noexcept
|
||||||
|
|
||||||
void sfz::FilePool::garbageJob() noexcept
|
void sfz::FilePool::garbageJob() noexcept
|
||||||
{
|
{
|
||||||
while (garbageFlag) {
|
while (semGarbageBarrier.wait(), garbageFlag) {
|
||||||
semGarbageBarrier.wait();
|
std::lock_guard<SpinMutex> guard { garbageMutex };
|
||||||
{
|
for (auto& g: garbageToCollect)
|
||||||
std::lock_guard<SpinMutex> guard { garbageMutex };
|
g.reset();
|
||||||
for (auto& g: garbageToCollect)
|
|
||||||
g.reset();
|
|
||||||
|
|
||||||
garbageToCollect.clear();
|
garbageToCollect.clear();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue