11 #ifndef ASIO_DETAIL_CHRONO_TIME_TRAITS_HPP 12 #define ASIO_DETAIL_CHRONO_TIME_TRAITS_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 26 template <
int64_t v1,
int64_t v2>
33 template <
typename Clock,
typename WaitTraits>
49 static time_type
now()
51 return clock_type::now();
55 static time_type
add(
const time_type& t,
const duration_type& d)
57 const time_type epoch;
60 if ((time_type::max)() - t < d)
61 return (time_type::max)();
65 if (-(t - (time_type::min)()) > d)
66 return (time_type::min)();
73 static duration_type
subtract(
const time_type& t1,
const time_type& t2)
75 const time_type epoch;
82 else if (t2 == (time_type::min)())
84 return (duration_type::max)();
86 else if ((time_type::max)() - t1 < epoch - t2)
88 return (duration_type::max)();
101 else if (t1 == (time_type::min)())
103 return (duration_type::min)();
105 else if ((time_type::max)() - t2 < epoch - t1)
107 return (duration_type::min)();
117 static bool less_than(
const time_type& t1,
const time_type& t2)
139 return duration_cast<1, 1>();
144 return duration_cast<1, 1000>();
149 return duration_cast<1, 1000000>();
153 template <
int64_t Num,
int64_t Den>
154 int64_t duration_cast()
const 162 const int64_t num = num1 * den2;
163 const int64_t den = num2 * den1;
165 if (num == 1 && den == 1)
167 else if (num != 1 && den == 1)
168 return ticks() * num;
169 else if (num == 1 && period_type::den != 1)
170 return ticks() / den;
172 return ticks() * num / den;
190 #endif // ASIO_DETAIL_CHRONO_TIME_TRAITS_HPP
duration_type::period period_type
int64_t total_seconds() const
int64_t total_microseconds() const
static bool less_than(const time_type &t1, const time_type &t2)
static duration_type subtract(const time_type &t1, const time_type &t2)
static time_type add(const time_type &t, const duration_type &d)
static posix_time_duration to_posix_duration(const duration_type &d)
int64_t total_milliseconds() const
clock_type::duration duration_type
clock_type::time_point time_type
posix_time_duration(const duration_type &d)