1#ifndef MSTL_CORE_TIME_CLOCKS_HPP__
2#define MSTL_CORE_TIME_CLOCKS_HPP__
35 static_assert(system_clock::duration::min() < system_clock::duration::zero(),
36 "a clock's minimum duration cannot be less than its epoch");
59 return time_point_value.since_epoch().to_sec();
105 template <typename Dur>
111 const auto diff = tp - steady_now;
175template <
typename Clock,
typename Dur>
177 auto current = Clock::now();
178 if (Clock::is_steady) {
179 if (current < time) {
184 while (current < time) {
186 current = Clock::now();
MSTL_INLINE17 constexpr bool is_clock_v
is_clock的便捷变量模板
milliseconds MSTL_API relative_time(int64_t sec, int64_t nsec, bool is_monotonic=false)
将绝对时间戳转换为相对延迟毫秒数
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
秒持续时间
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_BEGIN_THIS_THREAD__
this_thread命名空间
#define _THIS_THREAD
this_thread命名空间前缀
#define MSTL_END_THIS_THREAD__
结束this_thread命名空间
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
void sleep_until(const time_point< Clock, Dur > &time)
使当前线程睡眠直到指定时间点
void sleep_for(const duration< Rep, Period > time)
使当前线程睡眠指定时间
bool_constant< true > true_type
表示true的类型
typename Period::type period
时间单位比例类型
duration::period period
时间单位比例
static time_point now() noexcept
获取当前时间点
static system_clock::time_point to_system(const _MSTL time_point< steady_clock, Dur > &tp)
将稳定时钟转为系统时钟
_MSTL nanoseconds duration
持续时间类型
static constexpr bool is_steady
时钟稳定性标识
_MSTL time_point< steady_clock > time_point
时间点类型
_MSTL time_point< system_clock > time_point
时间点类型
static constexpr bool is_steady
时钟稳定性标识
static time_point now() noexcept
获取当前时间点
duration::period period
时间单位比例
_MSTL nanoseconds duration
持续时间类型
static seconds to_seconds(const time_point &time_point_value) noexcept
将时间点转换为时间值
static time_point from_seconds(const seconds time_value) noexcept
从时间值创建时间点