Skip to content

Commit fae86c3

Browse files
author
MarcoFalke
committed
util: Remove unused MilliSleep
1 parent fa9af06 commit fae86c3

File tree

5 files changed

+2
-91
lines changed

5 files changed

+2
-91
lines changed

build_msvc/bitcoin_config.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,6 @@
258258
/* Define if the visibility attribute is supported. */
259259
#define HAVE_VISIBILITY_ATTRIBUTE 1
260260

261-
/* Define this symbol if boost sleep works */
262-
/* #undef HAVE_WORKING_BOOST_SLEEP */
263-
264-
/* Define this symbol if boost sleep_for works */
265-
#define HAVE_WORKING_BOOST_SLEEP_FOR 1
266-
267261
/* Define to the sub-directory where libtool stores uninstalled libraries. */
268262
#define LT_OBJDIR ".libs/"
269263

configure.ac

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,57 +1231,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
12311231
LIBS="$TEMP_LIBS"
12321232
CPPFLAGS="$TEMP_CPPFLAGS"
12331233

1234-
dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
1235-
dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
1236-
dnl a working version is available, else fall back to sleep. sleep was removed
1237-
dnl after 1.56.
1238-
dnl If neither is available, abort.
1239-
TEMP_LIBS="$LIBS"
1240-
LIBS="$BOOST_LIBS $LIBS"
1241-
TEMP_CPPFLAGS="$CPPFLAGS"
1242-
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
1243-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1244-
#include <boost/thread/thread.hpp>
1245-
#include <boost/version.hpp>
1246-
]],[[
1247-
#if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
1248-
boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
1249-
#else
1250-
choke me
1251-
#endif
1252-
]])],
1253-
[boost_sleep=yes;
1254-
AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
1255-
[boost_sleep=no])
1256-
LIBS="$TEMP_LIBS"
1257-
CPPFLAGS="$TEMP_CPPFLAGS"
1258-
1259-
if test x$boost_sleep != xyes; then
1260-
TEMP_LIBS="$LIBS"
1261-
LIBS="$BOOST_LIBS $LIBS"
1262-
TEMP_CPPFLAGS="$CPPFLAGS"
1263-
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
1264-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1265-
#include <boost/version.hpp>
1266-
#include <boost/thread.hpp>
1267-
#include <boost/date_time/posix_time/posix_time_types.hpp>
1268-
]],[[
1269-
#if BOOST_VERSION <= 105600
1270-
boost::this_thread::sleep(boost::posix_time::milliseconds(0));
1271-
#else
1272-
choke me
1273-
#endif
1274-
]])],
1275-
[boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
1276-
[boost_sleep=no])
1277-
LIBS="$TEMP_LIBS"
1278-
CPPFLAGS="$TEMP_CPPFLAGS"
1279-
fi
1280-
1281-
if test x$boost_sleep != xyes; then
1282-
AC_MSG_ERROR(No working boost sleep implementation found.)
1283-
fi
1284-
12851234
fi
12861235

12871236
if test x$use_pkgconfig = xyes; then

src/test/scheduler_tests.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <random.h>
66
#include <scheduler.h>
7+
#include <util/time.h>
78

89
#include <boost/thread.hpp>
910
#include <boost/test/unit_test.hpp>
@@ -23,18 +24,6 @@ static void microTask(CScheduler& s, boost::mutex& mutex, int& counter, int delt
2324
}
2425
}
2526

26-
static void MicroSleep(uint64_t n)
27-
{
28-
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
29-
boost::this_thread::sleep_for(boost::chrono::microseconds(n));
30-
#elif defined(HAVE_WORKING_BOOST_SLEEP)
31-
boost::this_thread::sleep(boost::posix_time::microseconds(n));
32-
#else
33-
//should never get here
34-
#error missing boost sleep implementation
35-
#endif
36-
}
37-
3827
BOOST_AUTO_TEST_CASE(manythreads)
3928
{
4029
// Stress test: hundreds of microsecond-scheduled tasks,
@@ -81,7 +70,7 @@ BOOST_AUTO_TEST_CASE(manythreads)
8170
for (int i = 0; i < 5; i++)
8271
microThreads.create_thread(std::bind(&CScheduler::serviceQueue, &microTasks));
8372

84-
MicroSleep(600);
73+
UninterruptibleSleep(std::chrono::microseconds{600});
8574
now = boost::chrono::system_clock::now();
8675

8776
// More threads and more tasks:

src/util/time.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <atomic>
1313
#include <boost/date_time/posix_time/posix_time.hpp>
14-
#include <boost/thread.hpp>
1514
#include <ctime>
1615
#include <thread>
1716

@@ -76,24 +75,6 @@ int64_t GetSystemTimeInSeconds()
7675
return GetTimeMicros()/1000000;
7776
}
7877

79-
void MilliSleep(int64_t n)
80-
{
81-
82-
/**
83-
* Boost's sleep_for was uninterruptible when backed by nanosleep from 1.50
84-
* until fixed in 1.52. Use the deprecated sleep method for the broken case.
85-
* See: https://svn.boost.org/trac/boost/ticket/7238
86-
*/
87-
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
88-
boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
89-
#elif defined(HAVE_WORKING_BOOST_SLEEP)
90-
boost::this_thread::sleep(boost::posix_time::milliseconds(n));
91-
#else
92-
//should never get here
93-
#error missing boost sleep implementation
94-
#endif
95-
}
96-
9778
std::string FormatISO8601DateTime(int64_t nTime) {
9879
struct tm ts;
9980
time_t time_val = nTime;

src/util/time.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ void SetMockTime(int64_t nMockTimeIn);
3838
/** For testing */
3939
int64_t GetMockTime();
4040

41-
void MilliSleep(int64_t n);
42-
4341
/** Return system time (or mocked time, if set) */
4442
template <typename T>
4543
T GetTime();

0 commit comments

Comments
 (0)