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
util
syncmessenger.cpp
Go to the documentation of this file.
1
// Copyright (C) 2015 F4EXB //
3
// written by Edouard Griffiths //
4
// //
5
// This program is free software; you can redistribute it and/or modify //
6
// it under the terms of the GNU General Public License as published by //
7
// the Free Software Foundation as version 3 of the License, or //
8
// (at your option) any later version. //
9
// //
10
// This program is distributed in the hope that it will be useful, //
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13
// GNU General Public License V3 for more details. //
14
// //
15
// You should have received a copy of the GNU General Public License //
16
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
18
19
#include "
util/syncmessenger.h
"
20
#include "
util/message.h
"
21
22
SyncMessenger::SyncMessenger
() :
23
m_complete(0),
24
m_message(0),
25
m_result(0)
26
{
27
qRegisterMetaType<Message>(
"Message"
);
28
}
29
30
SyncMessenger::~SyncMessenger
()
31
{}
32
33
int
SyncMessenger::sendWait
(
Message
& message,
unsigned
long
msPollTime)
34
{
35
m_message
= &message;
36
m_mutex
.lock();
37
m_complete
.store(0);
38
39
emit
messageSent
();
40
41
while
(!
m_complete
.load())
42
{
43
m_waitCondition
.wait(&
m_mutex
, msPollTime);
44
}
45
46
int
result =
m_result
;
47
m_mutex
.unlock();
48
49
return
result;
50
}
51
52
void
SyncMessenger::done
(
int
result)
53
{
54
m_result
= result;
55
m_complete
.store(1);
56
m_waitCondition
.wakeAll();
57
}
58
59
60
Message
Definition:
message.h:25
SyncMessenger::~SyncMessenger
~SyncMessenger()
Definition:
syncmessenger.cpp:30
SyncMessenger::m_mutex
QMutex m_mutex
Definition:
syncmessenger.h:50
message.h
SyncMessenger::m_message
Message * m_message
Definition:
syncmessenger.h:52
syncmessenger.h
SyncMessenger::m_result
int m_result
Definition:
syncmessenger.h:53
SyncMessenger::m_complete
QAtomicInt m_complete
Definition:
syncmessenger.h:51
SyncMessenger::SyncMessenger
SyncMessenger()
Definition:
syncmessenger.cpp:22
SyncMessenger::m_waitCondition
QWaitCondition m_waitCondition
Definition:
syncmessenger.h:49
SyncMessenger::messageSent
void messageSent()
SyncMessenger::done
void done(int result=0)
Processing of the message is complete.
Definition:
syncmessenger.cpp:52
SyncMessenger::sendWait
int sendWait(Message &message, unsigned long msPollTime=100)
Send message and waits for its process completion.
Definition:
syncmessenger.cpp:33
Generated on Fri Aug 2 2019 17:56:33 for SDRAngel by
1.8.13