QTimer是否足够智能以重新同步自己 [英] Is QTimer smart enough to resynchronize itself

查看:91
本文介绍了QTimer是否足够智能以重新同步自己的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们从t0开始以100ms的间隔开始QTimer.

Let's say we start a QTimer with a 100ms interval at t0.

比方说,第一次超时发生在t0 + 100ms.好吧.

Let's say first timeout occurs at t0+100ms. Fine.

可以说,由于巨大的CPU负载和/或事件循环必须处理大量事件,第二次超时发生在t0 + 230ms.

Let's say that, due to huge CPU load and/or lots of events having to be handled by the event loop, second timeout occurs at t0+230ms.

比方说,CPU恢复到正常负载.他们有没有机会在t0 + 300ms发生第三次超时(QTimer对象意识到它已经晚了,并试图通过重新同步自身来纠正它),还是最有可能在t0 + 330ms发生超时?

Let's say CPU is back to normal load. Is their any chance that third timeout could occur at t0+300ms (QTimer object realising it was late and trying to correct that by resynchronizing itself), or will it most likely timeout at t0+330ms?

推荐答案

QTimer 文档:

如果系统繁忙或无法提供所需的精度,则所有计时器类型的超时时间都可能晚于预期的时间.在这种情况下,即使多次超时,Qt也会仅发出一次Activate(),然后将恢复原始间隔.

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.

我不确定我是否理解正确,但是很显然,它不会重新同步,并且第三次超时将在t0 + 330ms发生.

I'm not sure I understand this correctly but, apparently, it won't resynchronize itself and third timeout will occur at t0+330ms.

这篇关于QTimer是否足够智能以重新同步自己的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆