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



  • 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.


  • Lifetime Qt Champion

    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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.