mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-11 05:59:32 -04: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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
|
||||
#include "export.h"
|
||||
@ -51,6 +52,7 @@ private:
|
||||
QString m_fftwWisdomFileName;
|
||||
std::map<unsigned int, std::vector<AllocatedEngine>> m_fftEngineBySize;
|
||||
std::map<unsigned int, std::vector<AllocatedEngine>> m_invFFTEngineBySize;
|
||||
QMutex m_mutex;
|
||||
};
|
||||
|
||||
#endif // _SDRBASE_FFTWFACTORY_H
|
||||
|
Loading…
Reference in New Issue
Block a user