summaryrefslogtreecommitdiffhomepage
path: root/tracker-hatire/thread.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-05-04 11:40:50 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-05-04 11:45:04 +0200
commit3e90bbcf004ac543ff1cf6cac4c0c78b2d5927af (patch)
treeb39e5d3f41dd5aaac96bff178425e845098aab67 /tracker-hatire/thread.cpp
parent5410dce61c4da92760feeb5493b4574bfb854ec8 (diff)
tracker/hatire: try to optimize the polling path
Issue: #327
Diffstat (limited to 'tracker-hatire/thread.cpp')
-rwxr-xr-xtracker-hatire/thread.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp
index f8064896..a33d58e0 100755
--- a/tracker-hatire/thread.cpp
+++ b/tracker-hatire/thread.cpp
@@ -254,7 +254,8 @@ void hatire_thread::serial_info_impl()
void hatire_thread::on_serial_read()
{
- static constexpr int ms = 1000/200;
+ constexpr int hz = 90;
+ constexpr int ms = 1000/hz;
{
QMutexLocker lck(&data_mtx);
@@ -275,23 +276,24 @@ void hatire_thread::on_serial_read()
portable::sleep(ms);
}
-void hatire_thread::prepend_unread_data_nolock(const QByteArray &data)
+void hatire_thread::replace_data_nolock(QByteArray&& data)
{
- data_read.prepend(data);
+ data_read = std::move(data);
}
-QByteArray hatire_thread::flush_data_read_nolock()
+QByteArray& hatire_thread::send_data_read_nolock(bool& ret)
{
constexpr int packet_len = 30;
+ constexpr int cnt = 4;
+ constexpr int len = cnt * packet_len;
- if (data_read.length() < 4 * packet_len)
+ if (data_read.length() < len)
{
// we're requesting more than packet length to help resync the stream if needed
- return QByteArray();
+ ret = false;
}
+ else
+ ret = true;
- QByteArray ret = data_read.left(90);
- data_read = data_read.mid(90);
-
- return ret;
+ return data_read;
}