#include <chrono>
#include <cstdint>
#include <string>
Go to the source code of this file.
|
| struct | NodeClock |
| | Mockable clock in the context of tests, otherwise the system clock. More...
|
| |
|
| using | NodeSeconds = std::chrono::time_point<NodeClock, std::chrono::seconds> |
| |
| using | SteadyClock = std::chrono::steady_clock |
| |
| using | SteadySeconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::seconds> |
| |
| using | SteadyMilliseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds> |
| |
| using | SteadyMicroseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds> |
| |
| using | SystemClock = std::chrono::system_clock |
| |
| using | HoursDouble = std::chrono::duration<double, std::chrono::hours::period> |
| |
| using | SecondsDouble = std::chrono::duration<double, std::chrono::seconds::period> |
| |
| using | MillisecondsDouble = std::chrono::duration<double, std::chrono::milliseconds::period> |
| |
|
| void | UninterruptibleSleep (const std::chrono::microseconds &n) |
| |
| template<typename Dur1 , typename Dur2 > |
| constexpr auto | Ticks (Dur2 d) |
| | Helper to count the seconds of a duration/time_point.
|
| |
| template<typename Duration , typename Timepoint > |
| constexpr auto | TicksSinceEpoch (Timepoint t) |
| |
| constexpr int64_t | count_seconds (std::chrono::seconds t) |
| |
| constexpr int64_t | count_milliseconds (std::chrono::milliseconds t) |
| |
| constexpr int64_t | count_microseconds (std::chrono::microseconds t) |
| |
| int64_t | GetTime () |
| | DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
|
| |
| void | SetMockTime (int64_t nMockTimeIn) |
| | DEPRECATED Use SetMockTime with chrono type.
|
| |
| void | SetMockTime (std::chrono::seconds mock_time_in) |
| | For testing.
|
| |
| std::chrono::seconds | GetMockTime () |
| | For testing.
|
| |
| template<typename T > |
| T | Now () |
| | Return the current time point cast to the given precision.
|
| |
| template<typename T > |
| T | GetTime () |
| | DEPRECATED, see GetTime.
|
| |
| std::string | FormatISO8601DateTime (int64_t nTime) |
| | ISO 8601 formatting is preferred.
|
| |
| std::string | FormatISO8601Date (int64_t nTime) |
| |
| struct timeval | MillisToTimeval (int64_t nTimeout) |
| | Convert milliseconds to a struct timeval for e.g.
|
| |
| struct timeval | MillisToTimeval (std::chrono::milliseconds ms) |
| | Convert milliseconds to a struct timeval for e.g.
|
| |
◆ HoursDouble
| using HoursDouble = std::chrono::duration<double, std::chrono::hours::period> |
◆ MillisecondsDouble
| using MillisecondsDouble = std::chrono::duration<double, std::chrono::milliseconds::period> |
◆ NodeSeconds
◆ SecondsDouble
| using SecondsDouble = std::chrono::duration<double, std::chrono::seconds::period> |
◆ SteadyClock
◆ SteadyMicroseconds
| using SteadyMicroseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds> |
◆ SteadyMilliseconds
| using SteadyMilliseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds> |
◆ SteadySeconds
| using SteadySeconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::seconds> |
◆ SystemClock
◆ count_microseconds()
| int64_t count_microseconds |
( |
std::chrono::microseconds | t | ) |
|
|
constexpr |
◆ count_milliseconds()
| int64_t count_milliseconds |
( |
std::chrono::milliseconds | t | ) |
|
|
constexpr |
◆ count_seconds()
| int64_t count_seconds |
( |
std::chrono::seconds | t | ) |
|
|
constexpr |
◆ FormatISO8601Date()
| std::string FormatISO8601Date |
( |
int64_t | nTime | ) |
|
◆ FormatISO8601DateTime()
| std::string FormatISO8601DateTime |
( |
int64_t | nTime | ) |
|
ISO 8601 formatting is preferred.
Use the FormatISO8601{DateTime,Date} helper functions if possible.
Definition at line 46 of file time.cpp.
◆ GetMockTime()
| std::chrono::seconds GetMockTime |
( |
| ) |
|
For testing.
Definition at line 39 of file time.cpp.
◆ GetTime() [1/2]
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
ClockType is
- SteadyClock/std::chrono::steady_clock for steady time
- SystemClock/std::chrono::system_clock for system time
- NodeClock for mockable system time
Definition at line 44 of file time.cpp.
◆ GetTime() [2/2]
DEPRECATED, see GetTime.
Definition at line 97 of file time.h.
◆ MillisToTimeval() [1/2]
| struct timeval MillisToTimeval |
( |
int64_t | nTimeout | ) |
|
Convert milliseconds to a struct timeval for e.g.
select.
Definition at line 63 of file time.cpp.
◆ MillisToTimeval() [2/2]
| struct timeval MillisToTimeval |
( |
std::chrono::milliseconds | ms | ) |
|
Convert milliseconds to a struct timeval for e.g.
select.
Definition at line 71 of file time.cpp.
◆ Now()
Return the current time point cast to the given precision.
Only use this when an exact precision is needed, otherwise use T::clock::now() directly.
Definition at line 91 of file time.h.
◆ SetMockTime() [1/2]
| void SetMockTime |
( |
int64_t | nMockTimeIn | ) |
|
DEPRECATED Use SetMockTime with chrono type.
- Parameters
-
| [in] | nMockTimeIn | Time in seconds. |
Definition at line 32 of file time.cpp.
◆ SetMockTime() [2/2]
| void SetMockTime |
( |
std::chrono::seconds | mock_time_in | ) |
|
For testing.
Set e.g. with the setmocktime rpc, or -mocktime argument
Definition at line 33 of file time.cpp.
◆ Ticks()
template<typename Dur1 , typename Dur2 >
Helper to count the seconds of a duration/time_point.
All durations/time_points 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.
This helper is used to convert durations/time_points before passing them over an interface that doesn't support std::chrono (e.g. RPC, debug log, or the GUI)
Definition at line 45 of file time.h.
◆ TicksSinceEpoch()
template<typename Duration , typename Timepoint >
| auto TicksSinceEpoch |
( |
Timepoint | t | ) |
|
|
constexpr |
◆ UninterruptibleSleep()
| void UninterruptibleSleep |
( |
const std::chrono::microseconds & | n | ) |
|