From 67af16f0e2c7a349217edbb36145feb6617c25ee Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Thu, 15 Oct 2020 15:58:08 +0200 Subject: [PATCH] Move the lock guard --- src/sfizz/FilePool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sfizz/FilePool.cpp b/src/sfizz/FilePool.cpp index ca437d52..5be67c6e 100644 --- a/src/sfizz/FilePool.cpp +++ b/src/sfizz/FilePool.cpp @@ -476,13 +476,14 @@ void sfz::FilePool::dispatchingJob() noexcept continue; } + std::lock_guard guard { loadingJobsMutex }; + if (filesToLoad.try_pop(queuedData)) { loadingJobs.push_back( threadPool.enqueue([this](const QueuedFileData& data) { loadingJob(data); }, queuedData)); } // Clear finished jobs - std::lock_guard guard { loadingJobsMutex }; swapAndPopAll(loadingJobs, [](std::future& future) { return future.wait_for(std::chrono::seconds(0)) == std::future_status::ready; });