mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #16117: util: Replace boost sleep with std sleep
fae86c38bcutil: Remove unused MilliSleep (MarcoFalke)fa9af06d91scripted-diff: Replace MilliSleep with UninterruptibleSleep (MarcoFalke)fa4620be78util: Add UnintrruptibleSleep (MarcoFalke) Pull request description: We don't use the interruptible feature of boost's sleep anywhere, so replace it with the sleep in `std::thread` ACKs for top commit: ajtowns: ACKfae86c38bcquick code review practicalswift: ACKfae86c38bc-- patch looks correct sipa: Concept and code review ACKfae86c38bcfanquake: ACKfae86c38bc- note that an instance of `DHAVE_WORKING_BOOST_SLEEP_FOR` was missed in the [linter](https://github.com/bitcoin/bitcoin/blob/master/test/lint/extended-lint-cppcheck.sh#L69), but that can be cleaned up later. Tree-SHA512: 7c0f8eb197664b9f7d9fe6c472c77d384f11c797c913afc31de4b532e3b4fd9ea6dd174f92062ff9d1ec39b25e0900ca7c597435add87f0f2477d9557204848c
This commit is contained in:
@@ -11,10 +11,13 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <ctime>
|
||||
#include <thread>
|
||||
|
||||
#include <tinyformat.h>
|
||||
|
||||
void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread::sleep_for(n); }
|
||||
|
||||
static std::atomic<int64_t> nMockTime(0); //!< For unit testing
|
||||
|
||||
int64_t GetTime()
|
||||
@@ -72,24 +75,6 @@ int64_t GetSystemTimeInSeconds()
|
||||
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) {
|
||||
struct tm ts;
|
||||
time_t time_val = nTime;
|
||||
|
||||
Reference in New Issue
Block a user