1#ifndef NEFORCE_CORE_TIME_CLOCKS_HPP__
2#define NEFORCE_CORE_TIME_CLOCKS_HPP__
12NEFORCE_BEGIN_NAMESPACE__
58 return time_point_value.since_epoch().to_sec();
104 template <typename Dur>
109 const auto diff = tp - steady_now;
155NEFORCE_BEGIN_THIS_THREAD__
173template <
typename Clock,
typename Dur>
175 auto current = Clock::now();
176 if (Clock::is_steady) {
177 if (current <
time) {
178 this_thread::sleep_for(
time - current);
182 while (current <
time) {
183 this_thread::sleep_for(
time - current);
184 current = Clock::now();
190NEFORCE_END_THIS_THREAD__
192NEFORCE_END_NAMESPACE__
milliseconds NEFORCE_API relative_time(int64_t sec, int64_t nsec, bool is_monotonic=false) noexcept
将绝对时间戳转换为相对延迟毫秒数
NEFORCE_INLINE17 constexpr bool is_clock_v
is_clock的便捷变量模板
long long int64_t
64位有符号整数类型
duration< int64_t, milli > milliseconds
毫秒持续时间
duration< int64_t, nano > nanoseconds
纳秒持续时间
constexpr ToDur time_cast(const duration< Rep, Period > &value)
持续时间类型转换
duration< int64_t > seconds
秒持续时间
void sleep_until(const time_point< Clock, Dur > &time)
使当前线程睡眠直到指定时间点
bool_constant< true > true_type
表示true的类型
typename nano::type period
static constexpr duration zero() noexcept
获取零持续时间
static constexpr duration min() noexcept
获取最小持续时间
duration::period period
时间单位比例
static time_point now() noexcept
获取当前时间点
nanoseconds duration
持续时间类型
static system_clock::time_point to_system(const _NEFORCE time_point< steady_clock, Dur > &tp)
将稳定时钟转为系统时钟
static constexpr bool is_steady
时钟稳定性标识
_NEFORCE time_point< steady_clock > time_point
时间点类型
static constexpr bool is_steady
时钟稳定性标识
static time_point now() noexcept
获取当前时间点
duration::period period
时间单位比例
static seconds to_seconds(const time_point &time_point_value) noexcept
将时间点转换为时间值
nanoseconds duration
持续时间类型
static time_point from_seconds(const seconds time_value) noexcept
从时间值创建时间点
_NEFORCE time_point< system_clock > time_point
时间点类型