Skip to content

Commit fa4620b

Browse files
author
MarcoFalke
committed
util: Add UnintrruptibleSleep
1 parent 36f42e1 commit fa4620b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/util/time.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
#include <boost/date_time/posix_time/posix_time.hpp>
1414
#include <boost/thread.hpp>
1515
#include <ctime>
16+
#include <thread>
17+
1618
#include <tinyformat.h>
1719

20+
void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread::sleep_for(n); }
21+
1822
static std::atomic<int64_t> nMockTime(0); //!< For unit testing
1923

2024
int64_t GetTime()
@@ -124,4 +128,4 @@ int64_t ParseISO8601DateTime(const std::string& str)
124128
if (ptime.is_not_a_date_time() || epoch > ptime)
125129
return 0;
126130
return (ptime - epoch).total_seconds();
127-
}
131+
}

src/util/time.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <string>
1111
#include <chrono>
1212

13+
void UninterruptibleSleep(const std::chrono::microseconds& n);
14+
1315
/**
1416
* Helper to count the seconds of a duration.
1517
*

0 commit comments

Comments
 (0)