SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
sdrbase
channel
remotedataqueue.cpp
Go to the documentation of this file.
1
// Copyright (C) 2018 Edouard Griffiths, F4EXB. //
3
// //
4
// Remtoe sink channel (Rx) data blocks queue //
5
// //
6
// SDRangel can serve as a remote SDR front end that handles the interface //
7
// with a physical device and sends or receives the I/Q samples stream via UDP //
8
// to or from another SDRangel instance or any program implementing the same //
9
// protocol. The remote SDRangel is controlled via its Web REST API. //
10
// //
11
// This program is free software; you can redistribute it and/or modify //
12
// it under the terms of the GNU General Public License as published by //
13
// the Free Software Foundation as version 3 of the License, or //
14
// (at your option) any later version. //
15
// //
16
// This program is distributed in the hope that it will be useful, //
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
19
// GNU General Public License V3 for more details. //
20
// //
21
// You should have received a copy of the GNU General Public License //
22
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
24
25
#include <
channel/remotedatablock.h
>
26
#include <
channel/remotedataqueue.h
>
27
#include <QDebug>
28
#include <QMutexLocker>
29
30
RemoteDataQueue::RemoteDataQueue
(QObject* parent) :
31
QObject(parent),
32
m_lock(QMutex::Recursive),
33
m_queue()
34
{
35
}
36
37
RemoteDataQueue::~RemoteDataQueue
()
38
{
39
RemoteDataBlock
* data;
40
41
while
((data =
pop
()) != 0)
42
{
43
qDebug() <<
"RemoteDataQueue::~RemoteDataQueue: data block was still in queue"
;
44
delete
data;
45
}
46
}
47
48
void
RemoteDataQueue::push
(
RemoteDataBlock
* data,
bool
emitSignal)
49
{
50
if
(data)
51
{
52
m_lock
.lock();
53
m_queue
.append(data);
54
m_lock
.unlock();
55
}
56
57
if
(emitSignal)
58
{
59
emit
dataBlockEnqueued
();
60
}
61
}
62
63
RemoteDataBlock
*
RemoteDataQueue::pop
()
64
{
65
QMutexLocker locker(&
m_lock
);
66
67
if
(
m_queue
.isEmpty())
68
{
69
return
0;
70
}
71
else
72
{
73
return
m_queue
.takeFirst();
74
}
75
}
76
77
int
RemoteDataQueue::size
()
78
{
79
QMutexLocker locker(&
m_lock
);
80
81
return
m_queue
.size();
82
}
83
84
void
RemoteDataQueue::clear
()
85
{
86
QMutexLocker locker(&
m_lock
);
87
m_queue
.clear();
88
}
RemoteDataQueue::pop
RemoteDataBlock * pop()
Pop message from queue.
Definition:
remotedataqueue.cpp:63
remotedatablock.h
RemoteDataQueue::m_lock
QMutex m_lock
Definition:
remotedataqueue.h:53
RemoteDataQueue::m_queue
QQueue< RemoteDataBlock * > m_queue
Definition:
remotedataqueue.h:54
RemoteDataQueue::dataBlockEnqueued
void dataBlockEnqueued()
RemoteDataQueue::push
void push(RemoteDataBlock *dataBlock, bool emitSignal=true)
Push daa block onto queue.
Definition:
remotedataqueue.cpp:48
remotedataqueue.h
RemoteDataQueue::~RemoteDataQueue
~RemoteDataQueue()
Definition:
remotedataqueue.cpp:37
RemoteDataBlock
Definition:
remotedatablock.h:161
RemoteDataQueue::clear
void clear()
Empty queue.
Definition:
remotedataqueue.cpp:84
RemoteDataQueue::size
int size()
Returns queue size.
Definition:
remotedataqueue.cpp:77
RemoteDataQueue::RemoteDataQueue
RemoteDataQueue(QObject *parent=NULL)
Definition:
remotedataqueue.cpp:30
Generated on Fri Aug 2 2019 17:56:33 for SDRAngel by
1.8.13