Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to slow down a worker thread doing some scientific calculations?
Qt 6.11 is out! See what's new in the release blog

How to slow down a worker thread doing some scientific calculations?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 994 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    One of the big features of my application is to run scientific simulations. For this, I have a worker thread where I do all the scientific calculations, and then I have the main thread that handles all the GUI stuff, including updating plots using the scientific data that has been calculated. Now, that data can tends to get calculated very quickly, meaning that the plots also get updated very quickly. I would therefore like to slow the calculations down (and, as a result, the updates to the plots too). Right now, my solution consists of using QWaitCondition::wait(), but the problem is that the time to wait can only be expressed in milliseconds, and that really makes things far too slow now. My understanding is that on Windows (I am targetting Windows, Linux and OS X), we can't go lower than 1 ms. So be it, I guess. Still, what other solution/approach/etc. would you recommend to achieve a sub-millisecond delay in a thread? Or am I simply out of luck here?...

    Cheers, Alan.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I would rather "slow down" the other end. Since you get frequent update, cache them and only plot your update e.g. once per second, once per 100 of update etc… What suits you better.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved