|
Boost Users : |
From: Lars Hagstro (lars_at_[hidden])
Date: 2007-02-01 09:53:21
Yep, I agree. The thread sleep function is terrible.
I'd like a function that takes a boost::posix_time::time_duration.
One solution could be to add a simple utility function that just takes a
time_duration and returns an xtime. Then you could do;
boost::thread::sleep(boost::to_xtime(boost::posix_time::microseconds(230)));
Cheers
Lars
hongleij_at_[hidden] wrote:
> hi:
> it really a trouble thing for me to use boost::thread::sleep()
> :
> boost::xtime helloworldtime;
> boost::xtime_get(&helloworldtime, boost::TIME_UTC);
> helloworldtime.sec += 6;
> boost::thread::sleep(helloworldtime);
>
> i think
> "boost::thread::sleep(1500) //millisecond "
> may easy my programming;if have such interface;
> now i use :
>
> void thread_sleep(unsigned int interval) //millisecond
> {
> boost::xtime xt;
> boost::xtime_get(&xt, boost::TIME_UTC);
> int sec=interval/1000;
> int msec=interval-1000*sec;
> xt.nsec += 1000*1000*msec;
> xt.sec+= sec;
> boost::thread::sleep(xt);
> }
>
> best wishes;-)
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
> Ïë¼ÓÈëÂð£¿1.9ÒÚÓû§ÕýÔÚʹÓÃÍøÒ×ÓÊÏä www.126.com <http://www.126.com/>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net