diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-03-07 14:25:21 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-04-03 14:04:21 -0400 |
commit | 1b43bf0d3ae7b1fcde0c0e20c23c341540f4c8d2 (patch) | |
tree | ca5ce1b1cfaa0ac8bf6d6eb069a985fe685135e6 /src/util.h | |
parent | c8c2fbe07f1a5475aea3a2680af9130558c7e5c8 (diff) |
Rename util.h Sleep --> MilliSleep
Two reasons for this change:
1. Need to always use boost::thread's sleep, even on Windows, so the
sleeps can be interrupted (prior code used Windows' built-in Sleep).
2. I always forgot what units the old Sleep took.
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/util.h b/src/util.h index 2c26120339..5173686eda 100644 --- a/src/util.h +++ b/src/util.h @@ -100,13 +100,16 @@ T* alignup(T* p) #endif #else #define MAX_PATH 1024 -inline void Sleep(int64 n) +#endif + +inline void MilliSleep(int64 n) { - /*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly. - So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/ - boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n)); -} +#if BOOST_VERSION >= 105000 + boost::this_thread::sleep_for(boost::chrono::milliseconds(n)); +#else + boost::this_thread::sleep(boost::posix_time::milliseconds(n)); #endif +} /* This GNU C extension enables the compiler to check the format string against the parameters provided. * X is the number of the "format string" parameter, and Y is the number of the first variadic parameter. |