Is there a way to give a piece of code high priority in Qt?
-
I have a single-threaded Qt GUI app from where I'll need to read (periodically) some hardware inputs. The application takes some time to process the event loop, so I'm afraid of losing some input events if I rely on QTimer or something like that.
On a microcontroller running bare metal I would use a hardware timer and an interrupt service routine. But I don't know how to get a similar solution on a higher level environment like Qt.
The only thing that comes to my mind are threads, but before diving into concurrency issues I decided to come here and ask you if Qt have some other way of solving that problem.
What I need is to make sure a function runs periodically with an interval of ~10 or 20ms.
-
@rrd0 said in Is there a way to give a piece of code high priority in Qt?:
On a microcontroller running bare metal I would use a hardware timer and an interrupt service routine. But I don't know how to get a similar solution on a higher level environment like Qt.
You dont...or at least you cannot guarantee the RTOS behaviour with Qt. The general answer is "it depends". 10-20ms is not a particularly tight timing constraint, but directly reading hardware registers from within Qt is IMHO, not appropriate.