summaryrefslogtreecommitdiffhomepage
path: root/tracker-freepie-udp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-06-18 18:19:17 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-06-18 18:48:42 +0200
commite88c7b29ea9ec9fcd6ac6b15c965085152100d2e (patch)
tree6747fe7fa797e024b986ba624d05e6f59032f0ac /tracker-freepie-udp
parent646530b5f9ca5debe7a9b4840192e32e43f919bf (diff)
get rid of "volatile" abuse
We heavily used "volatile bool" to check if the thread loop should stop. But this functionality is already provided by Qt5's QThread::requestInterruption. In other cases, "volatile" is wonderfully underspecified so it's better to ditch its usage in favor of std::atomic<t>. At the time we don't appear to be using the "volatile" keyword except when calling win32's Interlocked*() family of functions as necessary. In freetrackclient's header the "volatile" qualifier was used as part of a typedef. This doesn't work. Use it as part of data declaration.
Diffstat (limited to 'tracker-freepie-udp')
-rw-r--r--tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp7
-rw-r--r--tracker-freepie-udp/ftnoir_tracker_freepie-udp.h1
2 files changed, 4 insertions, 4 deletions
diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
index 4c5d14ef..e5667ebb 100644
--- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
+++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
@@ -6,13 +6,13 @@
#include <cmath>
-tracker_freepie::tracker_freepie() : pose { 0,0,0, 0,0,0 }, should_quit(false)
+tracker_freepie::tracker_freepie() : pose { 0,0,0, 0,0,0 }
{
}
tracker_freepie::~tracker_freepie()
{
- should_quit = true;
+ requestInterruption();
wait();
}
@@ -42,7 +42,8 @@ void tracker_freepie::run() {
sock.bind(QHostAddress::Any, (unsigned short) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
- while (!should_quit) {
+ while (!isInterruptionRequested())
+ {
int order[] = {
bound<int>(s.idx_x, 0, 2),
bound<int>(s.idx_y, 0, 2),
diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.h b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.h
index 5a98e194..51a710f8 100644
--- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.h
+++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.h
@@ -42,7 +42,6 @@ private:
QUdpSocket sock;
settings s;
QMutex mtx;
- volatile bool should_quit;
};
class dialog_freepie : public ITrackerDialog