summaryrefslogtreecommitdiffhomepage
path: root/proto-simconnect/ftnoir_protocol_sc.h
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 /proto-simconnect/ftnoir_protocol_sc.h
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 'proto-simconnect/ftnoir_protocol_sc.h')
-rw-r--r--proto-simconnect/ftnoir_protocol_sc.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/proto-simconnect/ftnoir_protocol_sc.h b/proto-simconnect/ftnoir_protocol_sc.h
index 270d922d..93376885 100644
--- a/proto-simconnect/ftnoir_protocol_sc.h
+++ b/proto-simconnect/ftnoir_protocol_sc.h
@@ -11,8 +11,10 @@
*/
#pragma once
#include "api/plugin-api.hpp"
-
#include "ui_ftnoir_sccontrols.h"
+
+#include <atomic>
+
#include <QThread>
#include <QMessageBox>
#include <QSettings>
@@ -70,12 +72,12 @@ private:
void run() override;
- volatile float virtSCPosX;
- volatile float virtSCPosY;
- volatile float virtSCPosZ;
- volatile float virtSCRotX;
- volatile float virtSCRotY;
- volatile float virtSCRotZ;
+ std::atomic<float> virtSCPosX;
+ std::atomic<float> virtSCPosY;
+ std::atomic<float> virtSCPosZ;
+ std::atomic<float> virtSCRotX;
+ std::atomic<float> virtSCRotY;
+ std::atomic<float> virtSCRotZ;
importSimConnect_Open simconnect_open;
importSimConnect_Close simconnect_close;
@@ -84,7 +86,7 @@ private:
importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent;
HANDLE hSimConnect;
- volatile bool should_stop, should_reconnect;
+ std::atomic<bool> should_reconnect;
static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext);
settings s;
QLibrary SCClientLib;