Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:33:47

0001 //
0002 // wait_traits.hpp
0003 // ~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_WAIT_TRAITS_HPP
0012 #define BOOST_ASIO_WAIT_TRAITS_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/push_options.hpp>
0019 
0020 namespace boost {
0021 namespace asio {
0022 
0023 /// Wait traits suitable for use with the basic_waitable_timer class template.
0024 template <typename Clock>
0025 struct wait_traits
0026 {
0027   /// Convert a clock duration into a duration used for waiting.
0028   /**
0029    * @returns @c d.
0030    */
0031   static typename Clock::duration to_wait_duration(
0032       const typename Clock::duration& d)
0033   {
0034     return d;
0035   }
0036 
0037   /// Convert a clock duration into a duration used for waiting.
0038   /**
0039    * @returns @c d.
0040    */
0041   static typename Clock::duration to_wait_duration(
0042       const typename Clock::time_point& t)
0043   {
0044     typename Clock::time_point now = Clock::now();
0045     if (now + (Clock::duration::max)() < t)
0046       return (Clock::duration::max)();
0047     if (now + (Clock::duration::min)() > t)
0048       return (Clock::duration::min)();
0049     return t - now;
0050   }
0051 };
0052 
0053 } // namespace asio
0054 } // namespace boost
0055 
0056 #include <boost/asio/detail/pop_options.hpp>
0057 
0058 #endif // BOOST_ASIO_WAIT_TRAITS_HPP