Chris@16: // Chris@16: // detail/timer_queue_ptime.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP Chris@16: #define BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: Chris@16: struct forwarding_posix_time_traits : time_traits {}; Chris@16: Chris@16: // Template specialisation for the commonly used instantation. Chris@16: template <> Chris@16: class timer_queue > Chris@16: : public timer_queue_base Chris@16: { Chris@16: public: Chris@16: // The time type. Chris@16: typedef boost::posix_time::ptime time_type; Chris@16: Chris@16: // The duration type. Chris@16: typedef boost::posix_time::time_duration duration_type; Chris@16: Chris@16: // Per-timer data. Chris@16: typedef timer_queue::per_timer_data Chris@16: per_timer_data; Chris@16: Chris@16: // Constructor. Chris@16: BOOST_ASIO_DECL timer_queue(); Chris@16: Chris@16: // Destructor. Chris@16: BOOST_ASIO_DECL virtual ~timer_queue(); Chris@16: Chris@16: // Add a new timer to the queue. Returns true if this is the timer that is Chris@16: // earliest in the queue, in which case the reactor's event demultiplexing Chris@16: // function call may need to be interrupted and restarted. Chris@16: BOOST_ASIO_DECL bool enqueue_timer(const time_type& time, Chris@16: per_timer_data& timer, wait_op* op); Chris@16: Chris@16: // Whether there are no timers in the queue. Chris@16: BOOST_ASIO_DECL virtual bool empty() const; Chris@16: Chris@16: // Get the time for the timer that is earliest in the queue. Chris@16: BOOST_ASIO_DECL virtual long wait_duration_msec(long max_duration) const; Chris@16: Chris@16: // Get the time for the timer that is earliest in the queue. Chris@16: BOOST_ASIO_DECL virtual long wait_duration_usec(long max_duration) const; Chris@16: Chris@16: // Dequeue all timers not later than the current time. Chris@16: BOOST_ASIO_DECL virtual void get_ready_timers(op_queue& ops); Chris@16: Chris@16: // Dequeue all timers. Chris@16: BOOST_ASIO_DECL virtual void get_all_timers(op_queue& ops); Chris@16: Chris@16: // Cancel and dequeue operations for the given timer. Chris@16: BOOST_ASIO_DECL std::size_t cancel_timer( Chris@16: per_timer_data& timer, op_queue& ops, Chris@16: std::size_t max_cancelled = (std::numeric_limits::max)()); Chris@16: Chris@16: private: Chris@16: timer_queue impl_; Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_HEADER_ONLY) Chris@16: # include Chris@16: #endif // defined(BOOST_ASIO_HEADER_ONLY) Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_TIMER_QUEUE_PTIME_HPP