Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3KB

  1. //
  2. // wait_traits.hpp
  3. // ~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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. #ifndef ASIO_WAIT_TRAITS_HPP
  11. #define ASIO_WAIT_TRAITS_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/push_options.hpp"
  16. namespace asio {
  17. /// Wait traits suitable for use with the basic_waitable_timer class template.
  18. template <typename Clock>
  19. struct wait_traits
  20. {
  21. /// Convert a clock duration into a duration used for waiting.
  22. /**
  23. * @returns @c d.
  24. */
  25. static typename Clock::duration to_wait_duration(
  26. const typename Clock::duration& d)
  27. {
  28. return d;
  29. }
  30. /// Convert a clock duration into a duration used for waiting.
  31. /**
  32. * @returns @c d.
  33. */
  34. static typename Clock::duration to_wait_duration(
  35. const typename Clock::time_point& t)
  36. {
  37. typename Clock::time_point now = Clock::now();
  38. if (now + (Clock::duration::max)() < t)
  39. return (Clock::duration::max)();
  40. if (now + (Clock::duration::min)() > t)
  41. return (Clock::duration::min)();
  42. return t - now;
  43. }
  44. };
  45. } // namespace asio
  46. #include "asio/detail/pop_options.hpp"
  47. #endif // ASIO_WAIT_TRAITS_HPP