mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 04:41:55 -05:00
Revision of mutex locks in FIFOs
This commit is contained in:
parent
3792398c8b
commit
e3910c0aa1
@ -31,6 +31,7 @@ void DataFifo::create(unsigned int s)
|
||||
|
||||
void DataFifo::reset()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
m_suppressed = -1;
|
||||
m_fill = 0;
|
||||
m_head = 0;
|
||||
@ -39,7 +40,8 @@ void DataFifo::reset()
|
||||
|
||||
DataFifo::DataFifo(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_data()
|
||||
m_data(),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
m_suppressed = -1;
|
||||
m_size = 0;
|
||||
@ -50,7 +52,8 @@ DataFifo::DataFifo(QObject* parent) :
|
||||
|
||||
DataFifo::DataFifo(int size, QObject* parent) :
|
||||
QObject(parent),
|
||||
m_data()
|
||||
m_data(),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
m_suppressed = -1;
|
||||
create(size);
|
||||
@ -58,7 +61,8 @@ DataFifo::DataFifo(int size, QObject* parent) :
|
||||
|
||||
DataFifo::DataFifo(const DataFifo& other) :
|
||||
QObject(other.parent()),
|
||||
m_data(other.m_data)
|
||||
m_data(other.m_data),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
m_suppressed = -1;
|
||||
m_size = m_data.size();
|
||||
@ -75,8 +79,8 @@ DataFifo::~DataFifo()
|
||||
|
||||
bool DataFifo::setSize(int size)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
create(size);
|
||||
|
||||
return m_data.size() == size;
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,10 @@ class SDRBASE_API DataFifo : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QMutex m_mutex;
|
||||
QElapsedTimer m_msgRateTimer;
|
||||
int m_suppressed;
|
||||
|
||||
QByteArray m_data;
|
||||
QMutex m_mutex;
|
||||
|
||||
unsigned int m_size;
|
||||
unsigned int m_fill;
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
void SampleMIFifo::init(unsigned int nbStreams, unsigned int size)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
m_nbStreams = nbStreams;
|
||||
m_size = size;
|
||||
m_fill = 0;
|
||||
@ -52,12 +53,14 @@ SampleMIFifo::SampleMIFifo(QObject *parent) :
|
||||
m_nbStreams(0),
|
||||
m_size(0),
|
||||
m_fill(0),
|
||||
m_head(0)
|
||||
m_head(0),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
}
|
||||
|
||||
SampleMIFifo::SampleMIFifo(unsigned int nbStreams, unsigned int size, QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
init(nbStreams, size);
|
||||
}
|
||||
@ -235,6 +238,8 @@ void SampleMIFifo::readSync(
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (m_head < m_fill)
|
||||
{
|
||||
ipart1Begin = m_head;
|
||||
|
@ -27,13 +27,15 @@ SampleMOFifo::SampleMOFifo(QObject *parent) :
|
||||
{}
|
||||
|
||||
SampleMOFifo::SampleMOFifo(unsigned int nbStreams, unsigned int size, QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
init(nbStreams, size);
|
||||
}
|
||||
|
||||
void SampleMOFifo::init(unsigned int nbStreams, unsigned int size)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
m_data.resize(nbStreams);
|
||||
m_vReadCount.resize(nbStreams);
|
||||
m_vReadHead.resize(nbStreams);
|
||||
|
@ -32,6 +32,7 @@ void SampleSinkFifo::create(unsigned int s)
|
||||
|
||||
void SampleSinkFifo::reset()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
m_suppressed = -1;
|
||||
m_fill = 0;
|
||||
m_head = 0;
|
||||
@ -40,7 +41,8 @@ void SampleSinkFifo::reset()
|
||||
|
||||
SampleSinkFifo::SampleSinkFifo(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_data()
|
||||
m_data(),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
m_suppressed = -1;
|
||||
m_size = 0;
|
||||
@ -51,7 +53,8 @@ SampleSinkFifo::SampleSinkFifo(QObject* parent) :
|
||||
|
||||
SampleSinkFifo::SampleSinkFifo(int size, QObject* parent) :
|
||||
QObject(parent),
|
||||
m_data()
|
||||
m_data(),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
m_suppressed = -1;
|
||||
create(size);
|
||||
@ -59,7 +62,8 @@ SampleSinkFifo::SampleSinkFifo(int size, QObject* parent) :
|
||||
|
||||
SampleSinkFifo::SampleSinkFifo(const SampleSinkFifo& other) :
|
||||
QObject(other.parent()),
|
||||
m_data(other.m_data)
|
||||
m_data(other.m_data),
|
||||
m_mutex(QMutex::Recursive)
|
||||
{
|
||||
m_suppressed = -1;
|
||||
m_size = m_data.size();
|
||||
@ -76,8 +80,8 @@ SampleSinkFifo::~SampleSinkFifo()
|
||||
|
||||
bool SampleSinkFifo::setSize(int size)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
create(size);
|
||||
|
||||
return m_data.size() == (unsigned int)size;
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,10 @@ class SDRBASE_API SampleSinkFifo : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QMutex m_mutex;
|
||||
QElapsedTimer m_msgRateTimer;
|
||||
int m_suppressed;
|
||||
|
||||
SampleVector m_data;
|
||||
QMutex m_mutex;
|
||||
|
||||
unsigned int m_size;
|
||||
unsigned int m_fill;
|
||||
@ -50,7 +49,7 @@ public:
|
||||
|
||||
bool setSize(int size);
|
||||
void reset();
|
||||
inline unsigned int size() const { return m_size; }
|
||||
inline unsigned int size() { QMutexLocker mutexLocker(&m_mutex); unsigned int size = m_size; return size; }
|
||||
inline unsigned int fill() { QMutexLocker mutexLocker(&m_mutex); unsigned int fill = m_fill; return fill; }
|
||||
|
||||
unsigned int write(const quint8* data, unsigned int count);
|
||||
|
Loading…
Reference in New Issue
Block a user