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) 18 #include "asio/detail/cstdint.hpp" 20 #include "asio/detail/push_options.hpp" 26 template <
int64_t v1,
int64_t v2>
30 struct gcd<v1, 0> {
enum { value = v1 }; };
33 template <
typename Clock,
typename WaitTraits>
37 typedef Clock clock_type;
40 typedef typename clock_type::duration duration_type;
43 typedef typename clock_type::time_point time_type;
46 typedef typename duration_type::period period_type;
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)
132 int64_t ticks()
const 137 int64_t total_seconds()
const 139 return duration_cast<1, 1>();
142 int64_t total_milliseconds()
const 144 return duration_cast<1, 1000>();
147 int64_t total_microseconds()
const 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;
188 #include "asio/detail/pop_options.hpp" 190 #endif // ASIO_DETAIL_CHRONO_TIME_TRAITS_HPP Definition: chrono_time_traits.hpp:124
Definition: chrono_time_traits.hpp:34
Definition: chrono_time_traits.hpp:27
Definition: any_io_executor.hpp:28