From e33ce85a6a6f5b3c332cca7b6496c64a2dddef2a Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Tue, 3 Dec 2019 15:31:01 +0100 Subject: [PATCH] Added the concurrent queue to the filepool --- src/sfizz/FilePool.cpp | 6 +++--- src/sfizz/FilePool.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sfizz/FilePool.cpp b/src/sfizz/FilePool.cpp index dbda0e44..f1034e72 100644 --- a/src/sfizz/FilePool.cpp +++ b/src/sfizz/FilePool.cpp @@ -189,15 +189,15 @@ void sfz::FilePool::loadingThread() noexcept promisesToClean.clear(); if (emptyQueue) { - while(promiseQueue.pop()) { - + while(promiseQueue.try_dequeue(promise)) { + // We're just dequeuing } emptyQueue = false; continue; } if (!promiseQueue.try_dequeue(promise)) { - std::this_thread::sleep_for(1ms); + std::this_thread::sleep_for(0.1ms); continue; } diff --git a/src/sfizz/FilePool.h b/src/sfizz/FilePool.h index ec1a05b0..2d4b251e 100644 --- a/src/sfizz/FilePool.h +++ b/src/sfizz/FilePool.h @@ -31,7 +31,7 @@ #include #include #include "absl/strings/string_view.h" -#include "moodycamel/readerwriterqueue.h" +#include "moodycamel/concurrentqueue.h" #include #include @@ -141,7 +141,7 @@ private: fs::path rootDirectory; void loadingThread() noexcept; - moodycamel::ReaderWriterQueue promiseQueue; + moodycamel::ConcurrentQueue promiseQueue; uint32_t preloadSize { config::preloadSize }; Oversampling oversamplingFactor { config::defaultOversamplingFactor }; // Signals