1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-07 16:34:45 -04:00

FFTFactory: add mutex for thread safety. Implements issue #514

This commit is contained in:
f4exb
2020-05-01 04:56:04 +02:00
parent 871e22bb7b
commit 6ed6eff5f7
2 changed files with 7 additions and 1 deletions
+5 -1
View File
@@ -15,10 +15,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QMutexLocker>
#include "fftfactory.h"
FFTFactory::FFTFactory(const QString& fftwWisdomFileName) :
m_fftwWisdomFileName(fftwWisdomFileName)
m_fftwWisdomFileName(fftwWisdomFileName),
m_mutex(QMutex::Recursive)
{}
FFTFactory::~FFTFactory()
@@ -70,6 +72,7 @@ void FFTFactory::preallocate(
unsigned int FFTFactory::getEngine(unsigned int fftSize, bool inverse, FFTEngine **engine)
{
QMutexLocker mutexLocker(&m_mutex);
std::map<unsigned int, std::vector<AllocatedEngine>>& enginesBySize = inverse ?
m_invFFTEngineBySize : m_fftEngineBySize;
@@ -121,6 +124,7 @@ unsigned int FFTFactory::getEngine(unsigned int fftSize, bool inverse, FFTEngine
void FFTFactory::releaseEngine(unsigned int fftSize, bool inverse, unsigned int engineSequence)
{
QMutexLocker mutexLocker(&m_mutex);
std::map<unsigned int, std::vector<AllocatedEngine>>& enginesBySize = inverse ?
m_invFFTEngineBySize : m_fftEngineBySize;