2 // detail/timer_queue_ptime.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP
12 #define BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/time_traits.hpp>
19 #include <boost/asio/detail/timer_queue.hpp>
21 #include <boost/asio/detail/push_options.hpp>
23 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
29 struct forwarding_posix_time_traits : time_traits<boost::posix_time::ptime> {};
31 // Template specialisation for the commonly used instantation.
33 class timer_queue<time_traits<boost::posix_time::ptime> >
34 : public timer_queue_base
38 typedef boost::posix_time::ptime time_type;
41 typedef boost::posix_time::time_duration duration_type;
44 typedef timer_queue<forwarding_posix_time_traits>::per_timer_data
48 BOOST_ASIO_DECL timer_queue();
51 BOOST_ASIO_DECL virtual ~timer_queue();
53 // Add a new timer to the queue. Returns true if this is the timer that is
54 // earliest in the queue, in which case the reactor's event demultiplexing
55 // function call may need to be interrupted and restarted.
56 BOOST_ASIO_DECL bool enqueue_timer(const time_type& time,
57 per_timer_data& timer, wait_op* op);
59 // Whether there are no timers in the queue.
60 BOOST_ASIO_DECL virtual bool empty() const;
62 // Get the time for the timer that is earliest in the queue.
63 BOOST_ASIO_DECL virtual long wait_duration_msec(long max_duration) const;
65 // Get the time for the timer that is earliest in the queue.
66 BOOST_ASIO_DECL virtual long wait_duration_usec(long max_duration) const;
68 // Dequeue all timers not later than the current time.
69 BOOST_ASIO_DECL virtual void get_ready_timers(op_queue<operation>& ops);
71 // Dequeue all timers.
72 BOOST_ASIO_DECL virtual void get_all_timers(op_queue<operation>& ops);
74 // Cancel and dequeue operations for the given timer.
75 BOOST_ASIO_DECL std::size_t cancel_timer(
76 per_timer_data& timer, op_queue<operation>& ops,
77 std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
80 timer_queue<forwarding_posix_time_traits> impl_;
87 #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
89 #include <boost/asio/detail/pop_options.hpp>
91 #if defined(BOOST_ASIO_HEADER_ONLY)
92 # include <boost/asio/detail/impl/timer_queue_ptime.ipp>
93 #endif // defined(BOOST_ASIO_HEADER_ONLY)
95 #endif // BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP