From 9f24c2636ee40e453d4e840359ab40d49654dab5 Mon Sep 17 00:00:00 2001 From: paulfd Date: Sat, 28 Sep 2019 15:57:35 +0200 Subject: [PATCH] Finer lock/unlock for the garbage collection mutex --- sfizz/FilePool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sfizz/FilePool.cpp b/sfizz/FilePool.cpp index e10377f3..9acec5e7 100644 --- a/sfizz/FilePool.cpp +++ b/sfizz/FilePool.cpp @@ -145,16 +145,17 @@ void sfz::FilePool::loadingThread() noexcept void sfz::FilePool::garbageThread() noexcept { while (!quitThread) { + fileHandleMutex.lock(); for (auto handle = fileHandles.begin(); handle < fileHandles.end();) { if (handle->use_count() == 1) { handle->reset(); - std::lock_guard guard { fileHandleMutex }; std::iter_swap(handle, fileHandles.end() - 1); fileHandles.pop_back(); } else { handle++; } } + fileHandleMutex.unlock(); std::this_thread::sleep_for(200ms); } }