mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
scripted-diff: Replace MilliSleep with UninterruptibleSleep
This is safe because MilliSleep is never executed in a boost::thread,
the only type of thread that is interruptible.
* The RPC server uses std::thread
* The wallet is either executed in an RPC thread or the main thread
* bitcoin-cli, benchmarks and tests are only one thread (the main thread)
-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended -e 's/MilliSleep\((\S+)\);/UninterruptibleSleep(std::chrono::milliseconds{\1});/g' $(git grep -l MilliSleep)
-END VERIFY SCRIPT-
This commit is contained in:
@@ -1322,7 +1322,7 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime)
|
||||
SetMockTime(111);
|
||||
// Check that mock time does not change after a sleep
|
||||
for (const auto& num_sleep : {0, 1}) {
|
||||
MilliSleep(num_sleep);
|
||||
UninterruptibleSleep(std::chrono::milliseconds{num_sleep});
|
||||
BOOST_CHECK_EQUAL(111, GetTime()); // Deprecated time getter
|
||||
BOOST_CHECK_EQUAL(111, GetTime<std::chrono::seconds>().count());
|
||||
BOOST_CHECK_EQUAL(111000, GetTime<std::chrono::milliseconds>().count());
|
||||
@@ -1333,7 +1333,7 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime)
|
||||
// Check that system time changes after a sleep
|
||||
const auto ms_0 = GetTime<std::chrono::milliseconds>();
|
||||
const auto us_0 = GetTime<std::chrono::microseconds>();
|
||||
MilliSleep(1);
|
||||
UninterruptibleSleep(std::chrono::milliseconds{1});
|
||||
BOOST_CHECK(ms_0 < GetTime<std::chrono::milliseconds>());
|
||||
BOOST_CHECK(us_0 < GetTime<std::chrono::microseconds>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user