所以我创建了一些代码。我使用提升计时器。这是
while(1){
timerForCaptureFame.restart();
//some code
spendedTimeForCaptureFame = timerForCaptureFame.elapsed();
if(spendedTimeForCaptureFame < desiredTimeForCaptureFame){
boost::this_thread::sleep(boost::posix_time::milliseconds(desiredTimeForCaptureFame - spendedTimeForCaptureFame));
}
}
是否会发生这样desiredTimeForCaptureFame - spendedTimeForCaptureFame
将是&gt; 0但是boost会把它当作0并暂停线程吗?
答案 0 :(得分:2)
boost::this_thread::sleep(0)
不应该“暂停线程”;它应该立即返回。已发布有关boost::this_thread::sleep
挂起的错误报告,因此您可能已经遇到此错误 - 如果是这样,我会感激更多细节,因为我自己无法重现它。