diff --git a/core/components/time_util.hpp b/core/components/time_util.hpp index 7c94952..949c497 100644 --- a/core/components/time_util.hpp +++ b/core/components/time_util.hpp @@ -22,19 +22,19 @@ using namespace chrono; template class T_TimeUtil { public: - time_point zero() { return time_point(nanoseconds(0)); } - time_point now() { return move(T::now()); } - int64_t getus() { return duration_cast(T::now().time_since_epoch()).count(); } - int64_t gets() { return duration_cast(T::now().time_since_epoch()).count(); } - int64_t getms() { return duration_cast(T::now().time_since_epoch()).count(); } - int64_t geth() { return duration_cast(T::now().time_since_epoch()).count(); } - int64_t tpToMs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } - int64_t tpToUs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } - int64_t tpToS(time_point t) { return duration_cast(t.time_since_epoch()).count(); } - int64_t dToMs(nanoseconds ns) { return duration_cast(ns).count(); } - int64_t dToUs(nanoseconds ns) { return duration_cast(ns).count(); } - int64_t dToS(nanoseconds ns) { return duration_cast(ns).count(); } - int64_t dToNs(nanoseconds ns) { return ns.count(); } + time_point zero() { return time_point(nanoseconds(0)); } + time_point now() { return move(T::now()); } + int64_t getus() { return duration_cast(T::now().time_since_epoch()).count(); } + int64_t gets() { return duration_cast(T::now().time_since_epoch()).count(); } + int64_t getms() { return duration_cast(T::now().time_since_epoch()).count(); } + int64_t geth() { return duration_cast(T::now().time_since_epoch()).count(); } + int64_t tpToMs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } + int64_t tpToUs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } + int64_t tpToS(time_point t) { return duration_cast(t.time_since_epoch()).count(); } + int64_t dToMs(nanoseconds ns) { return duration_cast(ns).count(); } + int64_t dToUs(nanoseconds ns) { return duration_cast(ns).count(); } + int64_t dToS(nanoseconds ns) { return duration_cast(ns).count(); } + int64_t dToNs(nanoseconds ns) { return ns.count(); } inline time_point msToTp(int64_t ms) { time_point tp = time_point(milliseconds(ms)); return move(tp); @@ -48,7 +48,7 @@ class T_TimeUtil { inline time_point adds(int value) { return adds(T::now(), value); } inline time_point addms(int value) { return addms(T::now(), value); } inline time_point addus(int value) { return addus(T::now(), value); } - inline int64_t ms2us(int64_t ms) { return ms * 1000; } + inline int64_t ms2us(int64_t ms) { return ms * 1000; } /** * @brief 计算流逝时间 */ @@ -68,11 +68,16 @@ class T_TimeUtil { int64_t countdownTimeNs(time_point endtime) { return dToNs(endtime - T::now()); } }; -typedef T_TimeUtil tu_sys; -typedef T_TimeUtil tu_steady; +typedef T_TimeUtil tu_sys; // not use in future +typedef T_TimeUtil tu_steady; // not use in future +typedef time_point tp_sys; // not use in future +typedef time_point tp_steady; // not use in future -typedef time_point tp_sys; -typedef time_point tp_steady; +// new api name +typedef T_TimeUtil zsystem_clock; +typedef T_TimeUtil zsteady_clock; +typedef time_point zsystem_tp; +typedef time_point zsteady_tp; }; // namespace core } // namespace iflytop