Clementine
wait_traits.hpp
1 //
2 // wait_traits.hpp
3 // ~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_WAIT_TRAITS_HPP
12 #define ASIO_WAIT_TRAITS_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/push_options.hpp"
19 
20 namespace asio {
21 
23 template <typename Clock>
24 struct wait_traits
25 {
27 
30  static typename Clock::duration to_wait_duration(
31  const typename Clock::duration& d)
32  {
33  return d;
34  }
35 
37 
40  static typename Clock::duration to_wait_duration(
41  const typename Clock::time_point& t)
42  {
43  typename Clock::time_point now = Clock::now();
44  if (now + (Clock::duration::max)() < t)
45  return (Clock::duration::max)();
46  if (now + (Clock::duration::min)() > t)
47  return (Clock::duration::min)();
48  return t - now;
49  }
50 };
51 
52 } // namespace asio
53 
54 #include "asio/detail/pop_options.hpp"
55 
56 #endif // ASIO_WAIT_TRAITS_HPP
static Clock::duration to_wait_duration(const typename Clock::time_point &t)
Convert a clock duration into a duration used for waiting.
Definition: wait_traits.hpp:40
static Clock::duration to_wait_duration(const typename Clock::duration &d)
Convert a clock duration into a duration used for waiting.
Definition: wait_traits.hpp:30
Definition: any_io_executor.hpp:28