[Interest] QTimer and Qt::PreciseTimer

Joshua Grauman jnfo-c at grauman.com
Wed Jul 26 23:23:29 CEST 2017


Thanks so much for the response.

So do I have this right then?

QTimer doesn't use any actually timers in the OS (no system 
calls/interrupts). It is all handled internally by Qt's event loop. So if 
the OS doesn't give Qt CPU time, it will miss a timer. Calling 'nice' 
(Linux) on the process may help with this.

Josh


> On quarta-feira, 26 de julho de 2017 12:58:43 PDT Joshua Grauman wrote:
>> Hello all,
>>
>> I have a QTimer in my application that runs every 40ms. It doesn't run
>> continuously, but I recall the start function every time my timer function
>> is done so that the timer doesn't drift over time. My question though is
>> about timeout overrun. If the system is busy, and so the timer is late,
>> will Qt::PreciseTimer be more likely to return on time than
>> Qt::CoarseTimer? In other words, I'm ok with the 5% accuracy of
>> Qt::CoarseTimer normally (when the system isn't busy), but when the 40ms
>> timer is getting close to 60ms, I want to avoid timer overrun.
>
> The type of timer is not relevant. All timers behave the same way: if it's
> serviced as soon as it's available and the next wake up will always be the
> current time + interval (± coarseness, if applicable).
>
> Qt does not control when the OS gives us CPU time to service the timers. If
> you need that, you need to consult your OS API and create a high-priority
> thread or process, something that usually requires privilege elevation. Qt
> cannot help you there.
>
>> Does anyone have any more precise info about Qt::PreciseTimer than the
>> docs which say:
>>
>> "All timer types may time out later than expected if the system is busy
>> or unable to provide the requested accuracy. In such a case of timeout
>> overrun, Qt will emit activated() only once, even if multiple timeouts
>> have expired, and then will resume the original interval."
>
> There is no more info to be had.
>
> -- 
> Thiago Macieira - thiago.macieira (AT) intel.com
>  Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>


More information about the Interest mailing list