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.

100 lines
2.9KB

  1. //
  2. // detail/timer_queue_ptime.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_DETAIL_TIMER_QUEUE_PTIME_HPP
  11. #define ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #if defined(ASIO_HAS_BOOST_DATE_TIME)
  17. #include "asio/time_traits.hpp"
  18. #include "asio/detail/timer_queue.hpp"
  19. #include "asio/detail/push_options.hpp"
  20. namespace asio {
  21. namespace detail {
  22. struct forwarding_posix_time_traits : time_traits<boost::posix_time::ptime> {};
  23. // Template specialisation for the commonly used instantation.
  24. template <>
  25. class timer_queue<time_traits<boost::posix_time::ptime> >
  26. : public timer_queue_base
  27. {
  28. public:
  29. // The time type.
  30. typedef boost::posix_time::ptime time_type;
  31. // The duration type.
  32. typedef boost::posix_time::time_duration duration_type;
  33. // Per-timer data.
  34. typedef timer_queue<forwarding_posix_time_traits>::per_timer_data
  35. per_timer_data;
  36. // Constructor.
  37. ASIO_DECL timer_queue();
  38. // Destructor.
  39. ASIO_DECL virtual ~timer_queue();
  40. // Add a new timer to the queue. Returns true if this is the timer that is
  41. // earliest in the queue, in which case the reactor's event demultiplexing
  42. // function call may need to be interrupted and restarted.
  43. ASIO_DECL bool enqueue_timer(const time_type& time,
  44. per_timer_data& timer, wait_op* op);
  45. // Whether there are no timers in the queue.
  46. ASIO_DECL virtual bool empty() const;
  47. // Get the time for the timer that is earliest in the queue.
  48. ASIO_DECL virtual long wait_duration_msec(long max_duration) const;
  49. // Get the time for the timer that is earliest in the queue.
  50. ASIO_DECL virtual long wait_duration_usec(long max_duration) const;
  51. // Dequeue all timers not later than the current time.
  52. ASIO_DECL virtual void get_ready_timers(op_queue<operation>& ops);
  53. // Dequeue all timers.
  54. ASIO_DECL virtual void get_all_timers(op_queue<operation>& ops);
  55. // Cancel and dequeue operations for the given timer.
  56. ASIO_DECL std::size_t cancel_timer(
  57. per_timer_data& timer, op_queue<operation>& ops,
  58. std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
  59. // Move operations from one timer to another, empty timer.
  60. ASIO_DECL void move_timer(per_timer_data& target,
  61. per_timer_data& source);
  62. private:
  63. timer_queue<forwarding_posix_time_traits> impl_;
  64. };
  65. } // namespace detail
  66. } // namespace asio
  67. #include "asio/detail/pop_options.hpp"
  68. #if defined(ASIO_HEADER_ONLY)
  69. # include "asio/detail/impl/timer_queue_ptime.ipp"
  70. #endif // defined(ASIO_HEADER_ONLY)
  71. #endif // defined(ASIO_HAS_BOOST_DATE_TIME)
  72. #endif // ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP