From 234fb619559628850ba1558588e79a10319c08a6 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 2 Sep 2015 01:51:49 +0200 Subject: [PATCH] Deep redesign: replaced smelly Spinlock mutex by standard QMutex in message queue --- CMakeLists.txt | 4 ++-- Readme.md | 4 ++-- include/util/messagequeue.h | 4 ++-- sdrbase/util/messagequeue.cpp | 8 +++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6f8875d0..897610b61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Readme.md b/Readme.md index f3ccc779a..199ad6a3b 100644 --- a/Readme.md +++ b/Readme.md @@ -45,7 +45,7 @@ Use `cmake ../ -DV4L-RTL=ON` to build the Linux kernel driver for RTL-SDR (Exper

BladeRF

-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

RTL-SDR

-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: diff --git a/include/util/messagequeue.h b/include/util/messagequeue.h index 933786157..1e718978b 100644 --- a/include/util/messagequeue.h +++ b/include/util/messagequeue.h @@ -20,7 +20,7 @@ #include #include -#include "spinlock.h" +#include #include "util/export.h" class Message; @@ -42,7 +42,7 @@ signals: void messageEnqueued(); private: - Spinlock m_lock; + QMutex m_lock; QQueue m_queue; }; diff --git a/sdrbase/util/messagequeue.cpp b/sdrbase/util/messagequeue.cpp index 846c640f7..b435ed2bd 100644 --- a/sdrbase/util/messagequeue.cpp +++ b/sdrbase/util/messagequeue.cpp @@ -16,12 +16,13 @@ /////////////////////////////////////////////////////////////////////////////////// #include +#include #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(); }