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.

timer_queue_ptime.hpp 2.7KB

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