What is the best way to exit out of a loop after an elapsed time of 30ms in C++

后端 未结 9 1013
感动是毒
感动是毒 2020-12-11 13:24

What is the best way to exit out of a loop as close to 30ms as possible in C++. Polling boost:microsec_clock ? Polling QTime ? Something else?

Something like:

9条回答
  •  一个人的身影
    2020-12-11 14:09

    If you need to do work until a certain time has elapsed, then docflabby's answer is spot-on. However, if you just need to wait, doing nothing, until a specified time has elapsed, then you should use usleep()

提交回复
热议问题