Examples of boost::this_thread::sleep()
seem to use objects of boost::posix_time::milliseconds
. I've tried that and it works, but I am using boost::chrono
for checking the system clock etcetera. It seems to me I should be able to pass sleep()
a chrono::duration
like this:
boost::this_thread::sleep( boost::chrono::duration(10) );
But the compiler is giving me the following error:
... boost_1_49_0\boost/thread/win32/thread_data.hpp(171) : error C2039: 'total_milliseconds' : is not a member of 'boost::chrono::duration'
Which I find confusing. Am I right in thinking I should be able to do this? Will it be necessary to convert to a posix_time
?
boost::chrono::system_clock returns the system time. This is the time usually displayed on the desktop of your computer. If you change the time on your computer, boost::chrono::system_clock returns the new time.
Like this, use sleep_for
and seconds
boost::this_thread::sleep_for( boost::chrono::seconds(10) );
After verification this feature is not yet available in boost 1.49.0. All my apologies. This is only working in the trunk version of boost.
That means that it is not possible to call a sleep-like function without converting to a boost.datetime format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With