Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Go to the documentation of this file. 6 #if defined(HAVE_CONFIG_H) 7 #include <config/dash-config.h> 15 #include <boost/date_time/posix_time/posix_time.hpp> 16 #include <boost/thread.hpp> 24 int64_t mocktime =
nMockTime.load(std::memory_order_relaxed);
25 if (mocktime)
return mocktime;
27 time_t now = time(
nullptr);
35 const std::chrono::seconds mocktime{
nMockTime.load(std::memory_order_relaxed)};
37 return std::chrono::duration_cast<T>(
42 template std::chrono::seconds
GetTime();
43 template std::chrono::milliseconds
GetTime();
44 template std::chrono::microseconds
GetTime();
48 nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
53 return nMockTime.load(std::memory_order_relaxed);
58 int64_t now = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
65 int64_t now = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
83 #if defined(HAVE_WORKING_BOOST_SLEEP_FOR) 84 boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
85 #elif defined(HAVE_WORKING_BOOST_SLEEP) 86 boost::this_thread::sleep(boost::posix_time::milliseconds(n));
89 #error missing boost sleep implementation 95 static std::locale classic(std::locale::classic());
97 std::locale loc(classic,
new boost::posix_time::time_facet(pszFormat));
100 ss << boost::posix_time::from_time_t(nTime);
void MilliSleep(int64_t n)
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
void SetMockTime(int64_t nMockTimeIn)
For testing.
int64_t GetTimeMicros()
Returns the system time (not mockable)
int64_t GetTime()
Return system time (or mocked time, if set)
int64_t GetSystemTimeInSeconds()
Returns the system time (not mockable)
static std::atomic< int64_t > nMockTime(0)
For unit testing.
int64_t GetTimeMillis()
Returns the system time (not mockable)
int64_t GetMockTime()
For testing.