how to sleep a thread for specified milliseconds and/or nanoseconds

Hello, I'm using boost 1.35. Would someone please give example of best way to sleep for a specified duration of milliseconds or nanoseconds? It seems that xtime is being deprecated in the thread library, but the sleep function still wants an xtime? Thanks, Victor

Victor Whiskey Yankee wrote:
I'm using boost 1.35.
Would someone please give example of best way to sleep for a specified duration of milliseconds or nanoseconds?
boost::this_thread::sleep(boost::posix_time::milliseconds(10)); boost::this_thread::sleep(boost::posix_time::nanoseconds(10));
It seems that xtime is being deprecated in the thread library, but the sleep function still wants an xtime?
Yes, xtime is deprecated. KevinH -- Kevin Heifner heifner @ ociweb.com http://heifner.blogspot.com Object Computing, Inc. (OCI) www.ociweb.com

On Mon, May 19, 2008 at 11:55 AM, Victor Whiskey Yankee <victor.whiskey.yankee@gmail.com> wrote:
Great.Thank you!
Now, how can I sleep if I am not inside a boost::thread? When I try that, I get this compile error:
error: 'boost::this_thread' has not been declared
You can't not be in a thread. And that error usually means a missing include. http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#...

You mean there is not a sleep function anywhere in boost but inside boost::thread? Wow...that's incredible disappointment.
sleep() resides in this_thread namespace just include the appropriate header file _________________________________________________________________ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx

Victor Whiskey Yankee <victor.whiskey.yankee@gmail.com> writes:
Now, how can I sleep if I am not inside a boost::thread? When I try that, I get this compile error:
error: 'boost::this_thread' has not been declared
You can't not be in a thread. And that error usually means a missing include.
You mean there is not a sleep function anywhere in boost but inside boost::thread? Wow...that's incredible disappointment.<br> Maybe with signals or condition variable by chance?<br>
How does one sleep in main that allows milliseconds and is cross-platform with linux and windows xp?
boost::this_thread::sleep works in all threads, including those not started with boost::thread, such as main. However, you need to include the right header: #include <boost/thread/thread.hpp> Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Victor Whiskey Yankee <victor.whiskey.yankee@gmail.com> writes:
Would someone please give example of best way to sleep for a specified duration of milliseconds or nanoseconds?
boost::this_thread::sleep(boost::posix_time::milliseconds(3)); Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
participants (5)
-
Anthony Williams
-
Igor R.
-
Kevin Heifner
-
Scott McMurray
-
Victor Whiskey Yankee