Changeset View
Changeset View
Standalone View
Standalone View
src/util/time.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2019 The Bitcoin Core developers | // Copyright (c) 2009-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_UTIL_TIME_H | #ifndef BITCOIN_UTIL_TIME_H | ||||
#define BITCOIN_UTIL_TIME_H | #define BITCOIN_UTIL_TIME_H | ||||
#include <chrono> | #include <chrono> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <string> | #include <string> | ||||
void UninterruptibleSleep(const std::chrono::microseconds &n); | void UninterruptibleSleep(const std::chrono::microseconds &n); | ||||
/** | /** | ||||
* Helper to count the seconds of a duration. | |||||
* | |||||
* All durations should be using std::chrono and calling this should generally | |||||
* be avoided in code. Though, it is still preferred to an inline t.count() to | |||||
* protect against a reliance on the exact type of t. | |||||
*/ | |||||
inline int64_t count_seconds(std::chrono::seconds t) { | |||||
return t.count(); | |||||
} | |||||
/** | |||||
* DEPRECATED | * DEPRECATED | ||||
* Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable) | * Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable) | ||||
*/ | */ | ||||
int64_t GetTime(); | int64_t GetTime(); | ||||
/** Returns the system time (not mockable) */ | /** Returns the system time (not mockable) */ | ||||
int64_t GetTimeMillis(); | int64_t GetTimeMillis(); | ||||
/** Returns the system time (not mockable) */ | /** Returns the system time (not mockable) */ | ||||
Show All 22 Lines |