mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 12:51:49 -05:00
FFTFactory: add mutex for thread safety. Implements issue #514
This commit is contained in:
parent
578ac1db00
commit
42d6732147
@ -15,10 +15,12 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QMutexLocker>
|
||||||
#include "fftfactory.h"
|
#include "fftfactory.h"
|
||||||
|
|
||||||
FFTFactory::FFTFactory(const QString& fftwWisdomFileName) :
|
FFTFactory::FFTFactory(const QString& fftwWisdomFileName) :
|
||||||
m_fftwWisdomFileName(fftwWisdomFileName)
|
m_fftwWisdomFileName(fftwWisdomFileName),
|
||||||
|
m_mutex(QMutex::Recursive)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FFTFactory::~FFTFactory()
|
FFTFactory::~FFTFactory()
|
||||||
@ -70,6 +72,7 @@ void FFTFactory::preallocate(
|
|||||||
|
|
||||||
unsigned int FFTFactory::getEngine(unsigned int fftSize, bool inverse, FFTEngine **engine)
|
unsigned int FFTFactory::getEngine(unsigned int fftSize, bool inverse, FFTEngine **engine)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
std::map<unsigned int, std::vector<AllocatedEngine>>& enginesBySize = inverse ?
|
std::map<unsigned int, std::vector<AllocatedEngine>>& enginesBySize = inverse ?
|
||||||
m_invFFTEngineBySize : m_fftEngineBySize;
|
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)
|
void FFTFactory::releaseEngine(unsigned int fftSize, bool inverse, unsigned int engineSequence)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
std::map<unsigned int, std::vector<AllocatedEngine>>& enginesBySize = inverse ?
|
std::map<unsigned int, std::vector<AllocatedEngine>>& enginesBySize = inverse ?
|
||||||
m_invFFTEngineBySize : m_fftEngineBySize;
|
m_invFFTEngineBySize : m_fftEngineBySize;
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
@ -51,6 +52,7 @@ private:
|
|||||||
QString m_fftwWisdomFileName;
|
QString m_fftwWisdomFileName;
|
||||||
std::map<unsigned int, std::vector<AllocatedEngine>> m_fftEngineBySize;
|
std::map<unsigned int, std::vector<AllocatedEngine>> m_fftEngineBySize;
|
||||||
std::map<unsigned int, std::vector<AllocatedEngine>> m_invFFTEngineBySize;
|
std::map<unsigned int, std::vector<AllocatedEngine>> m_invFFTEngineBySize;
|
||||||
|
QMutex m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SDRBASE_FFTWFACTORY_H
|
#endif // _SDRBASE_FFTWFACTORY_H
|
||||||
|
Loading…
Reference in New Issue
Block a user