mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-18 15:45:49 -05:00
Deep redesign: replaced smelly Spinlock mutex by standard QMutex in message queue
This commit is contained in:
parent
4fba8144dc
commit
234fb61955
@ -116,7 +116,7 @@ set(sdrbase_SOURCES
|
|||||||
#sdrbase/util/miniz.cpp
|
#sdrbase/util/miniz.cpp
|
||||||
sdrbase/util/samplesourceserializer.cpp
|
sdrbase/util/samplesourceserializer.cpp
|
||||||
sdrbase/util/simpleserializer.cpp
|
sdrbase/util/simpleserializer.cpp
|
||||||
sdrbase/util/spinlock.cpp
|
#sdrbase/util/spinlock.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(sdrbase_HEADERS
|
set(sdrbase_HEADERS
|
||||||
@ -194,7 +194,7 @@ set(sdrbase_HEADERS
|
|||||||
#include/util/miniz.h
|
#include/util/miniz.h
|
||||||
include/util/samplesourceserializer.h
|
include/util/samplesourceserializer.h
|
||||||
include/util/simpleserializer.h
|
include/util/simpleserializer.h
|
||||||
include/util/spinlock.h
|
#include/util/spinlock.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(sdrbase_SOURCES
|
set(sdrbase_SOURCES
|
||||||
|
@ -45,7 +45,7 @@ Use `cmake ../ -DV4L-RTL=ON` to build the Linux kernel driver for RTL-SDR (Exper
|
|||||||
|
|
||||||
<h2>BladeRF</h2>
|
<h2>BladeRF</h2>
|
||||||
|
|
||||||
BladeRF is supported through the libbladerf library that should be installed in your system for proper build of the software and operation support.
|
BladeRF is supported through the libbladerf library that should be installed in your system for proper build of the software and operation support. Add `libbladerf-dev` to the list of dependencies to install.
|
||||||
|
|
||||||
If you use your own location for libbladeRF install directory you need to specify library and include locations. Example with `/opt/install/libbladerf` with the following defines on `cmake` command line:
|
If you use your own location for libbladeRF install directory you need to specify library and include locations. Example with `/opt/install/libbladerf` with the following defines on `cmake` command line:
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ The interface is built in the software and do not require additional libraries o
|
|||||||
|
|
||||||
<h2>RTL-SDR</h2>
|
<h2>RTL-SDR</h2>
|
||||||
|
|
||||||
RTL-SDR based dongles are supported through the librtlsdr library that should be installed in your system for proper build of the software and operation support.
|
RTL-SDR based dongles are supported through the librtlsdr library that should be installed in your system for proper build of the software and operation support. Add `librtlsdr-dev` to the list of dependencies to install.
|
||||||
|
|
||||||
If you use your own location for librtlsdr install directory you need to specify library and include locations. Example with `/opt/install/librtlsdr` with the following defines on `cmake` command line:
|
If you use your own location for librtlsdr install directory you need to specify library and include locations. Example with `/opt/install/librtlsdr` with the following defines on `cmake` command line:
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
#include "spinlock.h"
|
#include <QMutex>
|
||||||
#include "util/export.h"
|
#include "util/export.h"
|
||||||
|
|
||||||
class Message;
|
class Message;
|
||||||
@ -42,7 +42,7 @@ signals:
|
|||||||
void messageEnqueued();
|
void messageEnqueued();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Spinlock m_lock;
|
QMutex m_lock;
|
||||||
QQueue<Message*> m_queue;
|
QQueue<Message*> m_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,12 +16,13 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QMutexLocker>
|
||||||
#include "util/messagequeue.h"
|
#include "util/messagequeue.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
MessageQueue::MessageQueue(QObject* parent) :
|
MessageQueue::MessageQueue(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_lock(),
|
m_lock(QMutex::Recursive),
|
||||||
m_queue()
|
m_queue()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -54,7 +55,7 @@ void MessageQueue::push(Message* message, bool emitSignal)
|
|||||||
|
|
||||||
Message* MessageQueue::pop()
|
Message* MessageQueue::pop()
|
||||||
{
|
{
|
||||||
SpinlockHolder spinlockHolder(&m_lock);
|
QMutexLocker locker(&m_lock);
|
||||||
|
|
||||||
if (m_queue.isEmpty())
|
if (m_queue.isEmpty())
|
||||||
{
|
{
|
||||||
@ -68,12 +69,13 @@ Message* MessageQueue::pop()
|
|||||||
|
|
||||||
int MessageQueue::size()
|
int MessageQueue::size()
|
||||||
{
|
{
|
||||||
SpinlockHolder spinlockHolder(&m_lock);
|
QMutexLocker locker(&m_lock);
|
||||||
|
|
||||||
return m_queue.size();
|
return m_queue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageQueue::clear()
|
void MessageQueue::clear()
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker(&m_lock);
|
||||||
m_queue.clear();
|
m_queue.clear();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user