Am 22.10.2012 um 07:21 schrieb d3fault <[email protected]>:
>> ...If you only need to read from the serial port periodically, you can set
>> your backend up like I did for backend2 in the exampe... which also uses a
>> timer.
>>
If that implies getting rid of a 2nd "polling thread" entirely then that's
something I would have also suggested.
Using a simple QTimer which fires periodically, say, every 50 ms, has less
overhead than waking up a thread with the same periodicity. Plus it is simpler,
as no data has to protected my mutexes (=additional overhead).
If on the other hand data is incoming infrequently ("you would fire many times
the timer in vain") AND you have some sort of (hardware interrupt) signal that
new data is present, only then waking up a thread and process the data
asynchronously is more performant.
But if the data processing itself is time-consuming and blocking the gui in a
significant way, and you /really/ need to poll ("no hardware signal telling you
there's data") then you could combine a QTimer and thread: poll with a timer
("cheap"), and only IF there is data wake up the "data process" thread and let
it handle the data as long as there is data incoming (mute the timer in the
meantime!). As soon as no data is incoming anymore, start polling with the
timer and put the thread to sleep again.
Cheers,
Oliver_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest