summaryrefslogtreecommitdiffhomepage
path: root/tracker-hatire/thread.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-05-04 07:22:13 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-05-04 07:22:13 +0200
commit7f1f658fec4a1f50d78dc8b8c4efe22bb6a9636b (patch)
tree74fb6dd72ef461e57d007676a72b34777e3e0309 /tracker-hatire/thread.hpp
parent38dd6e55d20adfd830d834c394fc6ce7373a4805 (diff)
tracker/hatire: remove race
Don't prepend existing remaining data racing with add new data. Expose the lock as a public member.
Diffstat (limited to 'tracker-hatire/thread.hpp')
-rwxr-xr-x[-rw-r--r--]tracker-hatire/thread.hpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tracker-hatire/thread.hpp b/tracker-hatire/thread.hpp
index dd0d8c14..c4ce4761 100644..100755
--- a/tracker-hatire/thread.hpp
+++ b/tracker-hatire/thread.hpp
@@ -22,6 +22,12 @@ enum results
# include <QTimer>
#endif
+#ifdef __GNUC__
+# define unused(t, i) t __attribute__((unused)) i
+#else
+# define unused(t, i) t i
+#endif
+
struct thread_settings
{
QByteArray sCmdStart;
@@ -94,7 +100,6 @@ class hatire_thread : public QThread
QByteArray data_read;
serial_t com_port;
thread_settings s;
- QMutex data_mtx;
void run() override;
@@ -102,7 +107,7 @@ private slots:
void on_serial_read();
void teardown_serial();
- void sendcmd_impl(const QByteArray& cmd)
+ void sendcmd_impl(unused(const QByteArray, &cmd))
{
#ifndef HATIRE_DEBUG_LOGFILE
QByteArray Msg;
@@ -160,8 +165,10 @@ public:
~hatire_thread() override;
hatire_thread();
- void prepend_unread_data(const QByteArray& data);
+ void prepend_unread_data_nolock(const QByteArray& data);
- QByteArray flush_data_read();
+ QByteArray flush_data_read_nolock();
void Log(const QString& message);
+
+ QMutex data_mtx;
};