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.
This commit is contained in:
Gavin Andresen
2013-03-07 14:25:21 -05:00
parent c8c2fbe07f
commit 1b43bf0d3a
8 changed files with 37 additions and 34 deletions

View File

@@ -100,14 +100,17 @@ T* alignup(T* p)
#endif
#else
#define MAX_PATH 1024
inline void Sleep(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));
}
#endif
inline void MilliSleep(int64 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.
* Parameters count from 1.