2012-04-12 135 views
1

我想在升壓線程中等待1.5秒。使用boost :: xtime我可以等待整數秒:C++升級線程延遲

// Block on the queue/wait for data for up two seconds. 
boost::xtime_get(&xt, boost::TIME_UTC); 
xt.sec++; 
xt.sec++; 
.... 
_condition.timed_wait(_mutex, xt) 

我該如何等待1.5秒呢?

+0

我窺探的錯誤在製造以下不起作用。 – GregC 2012-04-12 22:19:19

回答

3

將在使用納秒和秒部分和0.5十億納秒增加,增加第二的1.5秒

xt.sec++; 
xt.nsec += 500000000; 
_condition.timed_wait(_mutex, xt);