util: Remove unused MilliSleep

pull/764/head
MarcoFalke 5 years ago
parent fa9af06d91
commit fae86c38bc
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -258,12 +258,6 @@
/* Define if the visibility attribute is supported. */ /* Define if the visibility attribute is supported. */
#define HAVE_VISIBILITY_ATTRIBUTE 1 #define HAVE_VISIBILITY_ATTRIBUTE 1
/* Define this symbol if boost sleep works */
/* #undef HAVE_WORKING_BOOST_SLEEP */
/* Define this symbol if boost sleep_for works */
#define HAVE_WORKING_BOOST_SLEEP_FOR 1
/* Define to the sub-directory where libtool stores uninstalled libraries. */ /* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/" #define LT_OBJDIR ".libs/"

@ -1231,57 +1231,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
LIBS="$TEMP_LIBS" LIBS="$TEMP_LIBS"
CPPFLAGS="$TEMP_CPPFLAGS" CPPFLAGS="$TEMP_CPPFLAGS"
dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
dnl a working version is available, else fall back to sleep. sleep was removed
dnl after 1.56.
dnl If neither is available, abort.
TEMP_LIBS="$LIBS"
LIBS="$BOOST_LIBS $LIBS"
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <boost/thread/thread.hpp>
#include <boost/version.hpp>
]],[[
#if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
#else
choke me
#endif
]])],
[boost_sleep=yes;
AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
[boost_sleep=no])
LIBS="$TEMP_LIBS"
CPPFLAGS="$TEMP_CPPFLAGS"
if test x$boost_sleep != xyes; then
TEMP_LIBS="$LIBS"
LIBS="$BOOST_LIBS $LIBS"
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <boost/version.hpp>
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
]],[[
#if BOOST_VERSION <= 105600
boost::this_thread::sleep(boost::posix_time::milliseconds(0));
#else
choke me
#endif
]])],
[boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
[boost_sleep=no])
LIBS="$TEMP_LIBS"
CPPFLAGS="$TEMP_CPPFLAGS"
fi
if test x$boost_sleep != xyes; then
AC_MSG_ERROR(No working boost sleep implementation found.)
fi
fi fi
if test x$use_pkgconfig = xyes; then if test x$use_pkgconfig = xyes; then

@ -4,6 +4,7 @@
#include <random.h> #include <random.h>
#include <scheduler.h> #include <scheduler.h>
#include <util/time.h>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
@ -23,18 +24,6 @@ static void microTask(CScheduler& s, boost::mutex& mutex, int& counter, int delt
} }
} }
static void MicroSleep(uint64_t n)
{
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
boost::this_thread::sleep_for(boost::chrono::microseconds(n));
#elif defined(HAVE_WORKING_BOOST_SLEEP)
boost::this_thread::sleep(boost::posix_time::microseconds(n));
#else
//should never get here
#error missing boost sleep implementation
#endif
}
BOOST_AUTO_TEST_CASE(manythreads) BOOST_AUTO_TEST_CASE(manythreads)
{ {
// Stress test: hundreds of microsecond-scheduled tasks, // Stress test: hundreds of microsecond-scheduled tasks,
@ -81,7 +70,7 @@ BOOST_AUTO_TEST_CASE(manythreads)
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
microThreads.create_thread(std::bind(&CScheduler::serviceQueue, &microTasks)); microThreads.create_thread(std::bind(&CScheduler::serviceQueue, &microTasks));
MicroSleep(600); UninterruptibleSleep(std::chrono::microseconds{600});
now = boost::chrono::system_clock::now(); now = boost::chrono::system_clock::now();
// More threads and more tasks: // More threads and more tasks:

@ -11,7 +11,6 @@
#include <atomic> #include <atomic>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>
#include <ctime> #include <ctime>
#include <thread> #include <thread>
@ -76,24 +75,6 @@ int64_t GetSystemTimeInSeconds()
return GetTimeMicros()/1000000; return GetTimeMicros()/1000000;
} }
void MilliSleep(int64_t n)
{
/**
* Boost's sleep_for was uninterruptible when backed by nanosleep from 1.50
* until fixed in 1.52. Use the deprecated sleep method for the broken case.
* See: https://svn.boost.org/trac/boost/ticket/7238
*/
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
#elif defined(HAVE_WORKING_BOOST_SLEEP)
boost::this_thread::sleep(boost::posix_time::milliseconds(n));
#else
//should never get here
#error missing boost sleep implementation
#endif
}
std::string FormatISO8601DateTime(int64_t nTime) { std::string FormatISO8601DateTime(int64_t nTime) {
struct tm ts; struct tm ts;
time_t time_val = nTime; time_t time_val = nTime;

@ -38,8 +38,6 @@ void SetMockTime(int64_t nMockTimeIn);
/** For testing */ /** For testing */
int64_t GetMockTime(); int64_t GetMockTime();
void MilliSleep(int64_t n);
/** Return system time (or mocked time, if set) */ /** Return system time (or mocked time, if set) */
template <typename T> template <typename T>
T GetTime(); T GetTime();

Loading…
Cancel
Save