Reviewing merge request #1420: Increased accuracy of QThread's msleep and usleep in Windows

Now these functions in most cases works with max possible precision.

Commits that would be merged:

Version 6
  • Version 1
  • Version 2
  • Version 2
  • Version 3
  • Version 4
  • Version 5
  • Version 6
  • 22d7b6c
  • 8032fcb
  • Icreased accuracy of msleep() & usleep() of QThread

Showing 22d7b6c-8032fcb

Comments

Pushed new version 1

Pushed new version 2

Pushed new version 2

Pushed new version 3

Pushed new version 4

+     } else //fallback, if there is problems with Perfomance Counter

brace symmetry rule …

+             SWITCH_THREAD();

huh, this will pretty much kill any accuracy.

Today I think about it too. :–)

Pushed new version 5

Pushed new version 6

→ State changed from New to Updated

I fix above issues.

hmm, not sure i like that:
– the clock speed may change during the sleep, so things will be off
– now that you don’t yield, you busy-loop. only for the below-millisecond range, but many short sleeps will still hog the cpu

let’s see what thiago thinks about this.

– the clock speed may change during the sleep, so things will be off

It is possible to add special workaround using GetTickCount64 to prevent waiting more than required.
QElapsedTimer (since Qt 4.8) also may return errorneous value when CPU frequency changed…

many short sleeps will still hog the cpu

I do not known how fix it. For example I can keep current implementation for msleep, but use new for usleep and add warning to the docs.

On stackoverflow.com suggested usleep implemented via select from winsock2. But it also has accuracy of standard Sleep. So I see only one way to implement these sleeps.

→ State changed from Updated to Closed

Thank you for your contribution. With Qt 4 having moved [1] under Open
Governance [2] as well, you can now contribute your changes via Gerrit
[3]. At the same time, contributions via Gitorious can no longer be
merged.

We would still like to see your patch on the new platform, and wish
for you to become a member of the Qt Project. Please read [4] and in
particular [5] to familiarize yourself with the new tools. You will
still find a read-only mirror of all Qt repositories on Gitorious.

With a much wider set of possible reviewers, we are also looking
forward to better response times to contributions. Looking forward to
your patch!

Please note that at this point in time Qt 4.8 is a bugfix only branch,
and all fixes should be submitted to Qt 5 first, as far as
applicable. Qt 4 master is closed.

The Nokia Qt team

[1] http://labs.qt.nokia.com/2012/01/10/qt-4-moved-to-open-governance/
[2] http://labs.qt.nokia.com/2011/10/21/the-qt-project-is-live/
[3] http://codereview.qt-project.org
[4] http://www.qt-project.org
[5] http://developer.qt.nokia.com/wiki/Gerrit_Introduction

Add a new comment:

Login or create an account to post a comment

How to apply this merge request to your repository