Chris@16
|
1 //
|
Chris@16
|
2 // detail/timer_queue_ptime.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP
|
Chris@16
|
12 #define BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/asio/time_traits.hpp>
|
Chris@16
|
19 #include <boost/asio/detail/timer_queue.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost {
|
Chris@16
|
26 namespace asio {
|
Chris@16
|
27 namespace detail {
|
Chris@16
|
28
|
Chris@16
|
29 struct forwarding_posix_time_traits : time_traits<boost::posix_time::ptime> {};
|
Chris@16
|
30
|
Chris@16
|
31 // Template specialisation for the commonly used instantation.
|
Chris@16
|
32 template <>
|
Chris@16
|
33 class timer_queue<time_traits<boost::posix_time::ptime> >
|
Chris@16
|
34 : public timer_queue_base
|
Chris@16
|
35 {
|
Chris@16
|
36 public:
|
Chris@16
|
37 // The time type.
|
Chris@16
|
38 typedef boost::posix_time::ptime time_type;
|
Chris@16
|
39
|
Chris@16
|
40 // The duration type.
|
Chris@16
|
41 typedef boost::posix_time::time_duration duration_type;
|
Chris@16
|
42
|
Chris@16
|
43 // Per-timer data.
|
Chris@16
|
44 typedef timer_queue<forwarding_posix_time_traits>::per_timer_data
|
Chris@16
|
45 per_timer_data;
|
Chris@16
|
46
|
Chris@16
|
47 // Constructor.
|
Chris@16
|
48 BOOST_ASIO_DECL timer_queue();
|
Chris@16
|
49
|
Chris@16
|
50 // Destructor.
|
Chris@16
|
51 BOOST_ASIO_DECL virtual ~timer_queue();
|
Chris@16
|
52
|
Chris@16
|
53 // Add a new timer to the queue. Returns true if this is the timer that is
|
Chris@16
|
54 // earliest in the queue, in which case the reactor's event demultiplexing
|
Chris@16
|
55 // function call may need to be interrupted and restarted.
|
Chris@16
|
56 BOOST_ASIO_DECL bool enqueue_timer(const time_type& time,
|
Chris@16
|
57 per_timer_data& timer, wait_op* op);
|
Chris@16
|
58
|
Chris@16
|
59 // Whether there are no timers in the queue.
|
Chris@16
|
60 BOOST_ASIO_DECL virtual bool empty() const;
|
Chris@16
|
61
|
Chris@16
|
62 // Get the time for the timer that is earliest in the queue.
|
Chris@16
|
63 BOOST_ASIO_DECL virtual long wait_duration_msec(long max_duration) const;
|
Chris@16
|
64
|
Chris@16
|
65 // Get the time for the timer that is earliest in the queue.
|
Chris@16
|
66 BOOST_ASIO_DECL virtual long wait_duration_usec(long max_duration) const;
|
Chris@16
|
67
|
Chris@16
|
68 // Dequeue all timers not later than the current time.
|
Chris@16
|
69 BOOST_ASIO_DECL virtual void get_ready_timers(op_queue<operation>& ops);
|
Chris@16
|
70
|
Chris@16
|
71 // Dequeue all timers.
|
Chris@16
|
72 BOOST_ASIO_DECL virtual void get_all_timers(op_queue<operation>& ops);
|
Chris@16
|
73
|
Chris@16
|
74 // Cancel and dequeue operations for the given timer.
|
Chris@16
|
75 BOOST_ASIO_DECL std::size_t cancel_timer(
|
Chris@16
|
76 per_timer_data& timer, op_queue<operation>& ops,
|
Chris@16
|
77 std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
|
Chris@16
|
78
|
Chris@16
|
79 private:
|
Chris@16
|
80 timer_queue<forwarding_posix_time_traits> impl_;
|
Chris@16
|
81 };
|
Chris@16
|
82
|
Chris@16
|
83 } // namespace detail
|
Chris@16
|
84 } // namespace asio
|
Chris@16
|
85 } // namespace boost
|
Chris@16
|
86
|
Chris@16
|
87 #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
Chris@16
|
88
|
Chris@16
|
89 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
90
|
Chris@16
|
91 #if defined(BOOST_ASIO_HEADER_ONLY)
|
Chris@16
|
92 # include <boost/asio/detail/impl/timer_queue_ptime.ipp>
|
Chris@16
|
93 #endif // defined(BOOST_ASIO_HEADER_ONLY)
|
Chris@16
|
94
|
Chris@16
|
95 #endif // BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP
|