Deep redesign: replaced smelly Spinlock mutex by standard QMutex in message queue

pull/6/head
f4exb 2015-09-02 01:51:49 +02:00
rodzic 4fba8144dc
commit 234fb61955
4 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -116,7 +116,7 @@ set(sdrbase_SOURCES
#sdrbase/util/miniz.cpp
sdrbase/util/samplesourceserializer.cpp
sdrbase/util/simpleserializer.cpp
sdrbase/util/spinlock.cpp
#sdrbase/util/spinlock.cpp
)
set(sdrbase_HEADERS
@ -194,7 +194,7 @@ set(sdrbase_HEADERS
#include/util/miniz.h
include/util/samplesourceserializer.h
include/util/simpleserializer.h
include/util/spinlock.h
#include/util/spinlock.h
)
set(sdrbase_SOURCES

Wyświetl plik

@ -45,7 +45,7 @@ Use `cmake ../ -DV4L-RTL=ON` to build the Linux kernel driver for RTL-SDR (Exper
<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:
@ -59,7 +59,7 @@ The interface is built in the software and do not require additional libraries o
<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:

Wyświetl plik

@ -20,7 +20,7 @@
#include <QObject>
#include <QQueue>
#include "spinlock.h"
#include <QMutex>
#include "util/export.h"
class Message;
@ -42,7 +42,7 @@ signals:
void messageEnqueued();
private:
Spinlock m_lock;
QMutex m_lock;
QQueue<Message*> m_queue;
};

Wyświetl plik

@ -16,12 +16,13 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMutexLocker>
#include "util/messagequeue.h"
#include "util/message.h"
MessageQueue::MessageQueue(QObject* parent) :
QObject(parent),
m_lock(),
m_lock(QMutex::Recursive),
m_queue()
{
}
@ -54,7 +55,7 @@ void MessageQueue::push(Message* message, bool emitSignal)
Message* MessageQueue::pop()
{
SpinlockHolder spinlockHolder(&m_lock);
QMutexLocker locker(&m_lock);
if (m_queue.isEmpty())
{
@ -68,12 +69,13 @@ Message* MessageQueue::pop()
int MessageQueue::size()
{
SpinlockHolder spinlockHolder(&m_lock);
QMutexLocker locker(&m_lock);
return m_queue.size();
}
void MessageQueue::clear()
{
QMutexLocker locker(&m_lock);
m_queue.clear();
}