Move the lock guard
This commit is contained in:
parent
a5647ab339
commit
67af16f0e2
1 changed files with 2 additions and 1 deletions
|
|
@ -476,13 +476,14 @@ void sfz::FilePool::dispatchingJob() noexcept
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<SpinMutex> guard { loadingJobsMutex };
|
||||||
|
|
||||||
if (filesToLoad.try_pop(queuedData)) {
|
if (filesToLoad.try_pop(queuedData)) {
|
||||||
loadingJobs.push_back(
|
loadingJobs.push_back(
|
||||||
threadPool.enqueue([this](const QueuedFileData& data) { loadingJob(data); }, queuedData));
|
threadPool.enqueue([this](const QueuedFileData& data) { loadingJob(data); }, queuedData));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear finished jobs
|
// Clear finished jobs
|
||||||
std::lock_guard<SpinMutex> guard { loadingJobsMutex };
|
|
||||||
swapAndPopAll(loadingJobs, [](std::future<void>& future) {
|
swapAndPopAll(loadingJobs, [](std::future<void>& future) {
|
||||||
return future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
|
return future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue