![]() |
Bitcoin Core
29.1.0
P2P Digital Currency
|
#include <chrono>#include <cstdint>#include <optional>#include <string>#include <string_view>Go to the source code of this file.
Classes | |
| struct | NodeClock |
| Mockable clock in the context of tests, otherwise the system clock. More... | |
| struct | MockableSteadyClock |
| Version of SteadyClock that is mockable in the context of tests (set the current value with SetMockTime), otherwise the system steady clock. More... | |
Typedefs | |
| 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 > |
Functions | |
| 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. More... | |
| 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. More... | |
| void | SetMockTime (int64_t nMockTimeIn) |
| DEPRECATED Use SetMockTime with chrono type. More... | |
| void | SetMockTime (std::chrono::seconds mock_time_in) |
| For testing. More... | |
| std::chrono::seconds | GetMockTime () |
| For testing. More... | |
| template<typename T > | |
| T | Now () |
| Return the current time point cast to the given precision. More... | |
| std::string | FormatISO8601DateTime (int64_t nTime) |
| ISO 8601 formatting is preferred. More... | |
| std::string | FormatISO8601Date (int64_t nTime) |
| std::optional< int64_t > | ParseISO8601DateTime (std::string_view str) |
| struct timeval | MillisToTimeval (int64_t nTimeout) |
| Convert milliseconds to a struct timeval for e.g. More... | |
| struct timeval | MillisToTimeval (std::chrono::milliseconds ms) |
| Convert milliseconds to a struct timeval for e.g. More... | |
| using HoursDouble = std::chrono::duration<double, std::chrono::hours::period> |
| using MillisecondsDouble = std::chrono::duration<double, std::chrono::milliseconds::period> |
| using NodeSeconds = std::chrono::time_point<NodeClock, std::chrono::seconds> |
| using SecondsDouble = std::chrono::duration<double, std::chrono::seconds::period> |
| using SteadyClock = std::chrono::steady_clock |
| using SteadyMicroseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds> |
| using SteadyMilliseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds> |
| using SteadySeconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::seconds> |
| using SystemClock = std::chrono::system_clock |
| constexpr int64_t count_microseconds | ( | std::chrono::microseconds | t | ) |
| constexpr int64_t count_milliseconds | ( | std::chrono::milliseconds | t | ) |
| constexpr int64_t count_seconds | ( | std::chrono::seconds | t | ) |
| std::string FormatISO8601Date | ( | int64_t | nTime | ) |
| std::string FormatISO8601DateTime | ( | int64_t | nTime | ) |
| std::chrono::seconds GetMockTime | ( | ) |
| int64_t GetTime | ( | ) |
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
DEPRECATED, see GetTime.
ClockType is
| struct timeval MillisToTimeval | ( | std::chrono::milliseconds | ms | ) |
| struct timeval MillisToTimeval | ( | int64_t | nTimeout | ) |
| T Now | ( | ) |
| std::optional<int64_t> ParseISO8601DateTime | ( | std::string_view | str | ) |
| void SetMockTime | ( | int64_t | nMockTimeIn | ) |
| void SetMockTime | ( | std::chrono::seconds | mock_time_in | ) |
| constexpr auto Ticks | ( | Dur2 | d | ) |
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)
| constexpr auto TicksSinceEpoch | ( | Timepoint | t | ) |
1.8.14