Skip to content

Commit 11ba4e0

Browse files
authored
Merge pull request #2231 from barton2526/boost2
util: Remove old boost hacks/workarounds
2 parents ab2ef19 + d6f1721 commit 11ba4e0

File tree

4 files changed

+6
-59
lines changed

4 files changed

+6
-59
lines changed

configure.ac

+2-27
Original file line numberDiff line numberDiff line change
@@ -908,11 +908,8 @@ if test x$use_boost = xyes; then
908908

909909
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_ZLIB_LIB $BOOST_IOSTREAMS_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB $BOOST_ZLIB_LIB"
910910

911-
dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
912-
dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
913-
dnl a working version is available, else fall back to sleep. sleep was removed
914-
dnl after 1.56.
915-
dnl If neither is available, abort.
911+
dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep.
912+
dnl Use sleep_for if a working version is available. If not, abort.
916913
TEMP_LIBS="$LIBS"
917914
LIBS="$BOOST_LIBS $LIBS"
918915
TEMP_CPPFLAGS="$CPPFLAGS"
@@ -933,28 +930,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
933930
LIBS="$TEMP_LIBS"
934931
CPPFLAGS="$TEMP_CPPFLAGS"
935932

936-
if test x$boost_sleep != xyes; then
937-
TEMP_LIBS="$LIBS"
938-
LIBS="$BOOST_LIBS $LIBS"
939-
TEMP_CPPFLAGS="$CPPFLAGS"
940-
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
941-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
942-
#include <boost/version.hpp>
943-
#include <boost/thread.hpp>
944-
#include <boost/date_time/posix_time/posix_time_types.hpp>
945-
]],[[
946-
#if BOOST_VERSION <= 105600
947-
boost::this_thread::sleep(boost::posix_time::milliseconds(0));
948-
#else
949-
choke me
950-
#endif
951-
]])],
952-
[boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
953-
[boost_sleep=no])
954-
LIBS="$TEMP_LIBS"
955-
CPPFLAGS="$TEMP_CPPFLAGS"
956-
fi
957-
958933
if test x$boost_sleep != xyes; then
959934
AC_MSG_ERROR(No working boost sleep implementation found.)
960935
fi

src/gridcoin/backup.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,8 @@ bool GRC::BackupConfigFile(const std::string& strDest)
123123
{
124124
#if BOOST_VERSION >= 107400
125125
fs::copy_file(ConfigSource, ConfigTarget, fs::copy_options::overwrite_existing);
126-
#elif BOOST_VERSION >= 104000
127-
fs::copy_file(ConfigSource, ConfigTarget, fs::copy_option::overwrite_if_exists);
128126
#else
129-
fs::copy_file(ConfigSource, ConfigTarget);
127+
fs::copy_file(ConfigSource, ConfigTarget, fs::copy_option::overwrite_if_exists);
130128
#endif
131129
LogPrintf("BackupConfigFile: Copied gridcoinresearch.conf to %s", ConfigTarget.string());
132130
return true;
@@ -164,10 +162,8 @@ bool GRC::BackupWallet(const CWallet& wallet, const std::string& strDest)
164162
{
165163
#if BOOST_VERSION >= 107400
166164
fs::copy_file(WalletSource, WalletTarget, fs::copy_options::overwrite_existing);
167-
#elif BOOST_VERSION >= 104000
168-
fs::copy_file(WalletSource, WalletTarget, fs::copy_option::overwrite_if_exists);
169165
#else
170-
fs::copy_file(WalletSource, WalletTarget);
166+
fs::copy_file(WalletSource, WalletTarget, fs::copy_option::overwrite_if_exists);
171167
#endif
172168
LogPrintf("BackupWallet: Copied wallet.dat to %s", WalletTarget.string());
173169
}

src/scheduler.cpp

+1-18
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ CScheduler::~CScheduler()
2020
assert(nThreadsServicingQueue == 0);
2121
}
2222

23-
24-
#if BOOST_VERSION < 105000
25-
static boost::system_time toPosixTime(const boost::chrono::system_clock::time_point& t)
26-
{
27-
// Creating the posix_time using from_time_t loses sub-second precision. So rather than exporting the time_point to time_t,
28-
// start with a posix_time at the epoch (0) and add the milliseconds that have passed since then.
29-
return boost::posix_time::from_time_t(0) + boost::posix_time::milliseconds(boost::chrono::duration_cast<boost::chrono::milliseconds>(t.time_since_epoch()).count());
30-
}
31-
#endif
32-
3323
void CScheduler::serviceQueue()
3424
{
3525
boost::unique_lock<boost::mutex> lock(newTaskMutex);
@@ -54,13 +44,6 @@ void CScheduler::serviceQueue()
5444
// Wait until either there is a new task, or until
5545
// the time of the first item on the queue:
5646

57-
// wait_until needs boost 1.50 or later; older versions have timed_wait:
58-
#if BOOST_VERSION < 105000
59-
while (!shouldStop() && !taskQueue.empty() &&
60-
newTaskScheduled.timed_wait(lock, toPosixTime(taskQueue.begin()->first))) {
61-
// Keep waiting until timeout
62-
}
63-
#else
6447
// Some boost versions have a conflicting overload of wait_until that returns void.
6548
// Explicitly use a template here to avoid hitting that overload.
6649
while (!shouldStop() && !taskQueue.empty()) {
@@ -80,7 +63,7 @@ void CScheduler::serviceQueue()
8063
throw;
8164
}
8265
}
83-
#endif
66+
8467
// If there are multiple threads, the queue can empty while we're waiting (another
8568
// thread may service the task we were waiting on).
8669
if (shouldStop() || taskQueue.empty())

src/util/time.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,11 @@ MilliTimer g_timer;
186186
void MilliSleep(int64_t n)
187187
{
188188

189-
/**
190-
* Boost's sleep_for was uninterruptible when backed by nanosleep from 1.50
191-
* until fixed in 1.52. Use the deprecated sleep method for the broken case.
192-
* See: https://svn.boost.org/trac/boost/ticket/7238
193-
*/
194189
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
195190
boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
196-
#elif defined(HAVE_WORKING_BOOST_SLEEP)
197-
boost::this_thread::sleep(boost::posix_time::milliseconds(n));
198191
#else
199192
//should never get here
200-
#error missing boost sleep implementation
193+
#error missing boost sleep_for implementation
201194
#endif
202195
}
203196

0 commit comments

Comments
 (0)