annotate DEPENDENCIES/generic/include/boost/asio/deadline_timer_service.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // deadline_timer_service.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_DEADLINE_TIMER_SERVICE_HPP
Chris@16 12 #define BOOST_ASIO_DEADLINE_TIMER_SERVICE_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/detail/config.hpp>
Chris@16 19
Chris@16 20 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
Chris@16 21 || defined(GENERATING_DOCUMENTATION)
Chris@16 22
Chris@16 23 #include <cstddef>
Chris@16 24 #include <boost/asio/async_result.hpp>
Chris@16 25 #include <boost/asio/detail/deadline_timer_service.hpp>
Chris@16 26 #include <boost/asio/io_service.hpp>
Chris@16 27 #include <boost/asio/time_traits.hpp>
Chris@16 28 #include <boost/asio/detail/timer_queue_ptime.hpp>
Chris@16 29
Chris@16 30 #include <boost/asio/detail/push_options.hpp>
Chris@16 31
Chris@16 32 namespace boost {
Chris@16 33 namespace asio {
Chris@16 34
Chris@16 35 /// Default service implementation for a timer.
Chris@16 36 template <typename TimeType,
Chris@16 37 typename TimeTraits = boost::asio::time_traits<TimeType> >
Chris@16 38 class deadline_timer_service
Chris@16 39 #if defined(GENERATING_DOCUMENTATION)
Chris@16 40 : public boost::asio::io_service::service
Chris@16 41 #else
Chris@16 42 : public boost::asio::detail::service_base<
Chris@16 43 deadline_timer_service<TimeType, TimeTraits> >
Chris@16 44 #endif
Chris@16 45 {
Chris@16 46 public:
Chris@16 47 #if defined(GENERATING_DOCUMENTATION)
Chris@16 48 /// The unique service identifier.
Chris@16 49 static boost::asio::io_service::id id;
Chris@16 50 #endif
Chris@16 51
Chris@16 52 /// The time traits type.
Chris@16 53 typedef TimeTraits traits_type;
Chris@16 54
Chris@16 55 /// The time type.
Chris@16 56 typedef typename traits_type::time_type time_type;
Chris@16 57
Chris@16 58 /// The duration type.
Chris@16 59 typedef typename traits_type::duration_type duration_type;
Chris@16 60
Chris@16 61 private:
Chris@16 62 // The type of the platform-specific implementation.
Chris@16 63 typedef detail::deadline_timer_service<traits_type> service_impl_type;
Chris@16 64
Chris@16 65 public:
Chris@16 66 /// The implementation type of the deadline timer.
Chris@16 67 #if defined(GENERATING_DOCUMENTATION)
Chris@16 68 typedef implementation_defined implementation_type;
Chris@16 69 #else
Chris@16 70 typedef typename service_impl_type::implementation_type implementation_type;
Chris@16 71 #endif
Chris@16 72
Chris@16 73 /// Construct a new timer service for the specified io_service.
Chris@16 74 explicit deadline_timer_service(boost::asio::io_service& io_service)
Chris@16 75 : boost::asio::detail::service_base<
Chris@16 76 deadline_timer_service<TimeType, TimeTraits> >(io_service),
Chris@16 77 service_impl_(io_service)
Chris@16 78 {
Chris@16 79 }
Chris@16 80
Chris@16 81 /// Construct a new timer implementation.
Chris@16 82 void construct(implementation_type& impl)
Chris@16 83 {
Chris@16 84 service_impl_.construct(impl);
Chris@16 85 }
Chris@16 86
Chris@16 87 /// Destroy a timer implementation.
Chris@16 88 void destroy(implementation_type& impl)
Chris@16 89 {
Chris@16 90 service_impl_.destroy(impl);
Chris@16 91 }
Chris@16 92
Chris@16 93 /// Cancel any asynchronous wait operations associated with the timer.
Chris@16 94 std::size_t cancel(implementation_type& impl, boost::system::error_code& ec)
Chris@16 95 {
Chris@16 96 return service_impl_.cancel(impl, ec);
Chris@16 97 }
Chris@16 98
Chris@16 99 /// Cancels one asynchronous wait operation associated with the timer.
Chris@16 100 std::size_t cancel_one(implementation_type& impl,
Chris@16 101 boost::system::error_code& ec)
Chris@16 102 {
Chris@16 103 return service_impl_.cancel_one(impl, ec);
Chris@16 104 }
Chris@16 105
Chris@16 106 /// Get the expiry time for the timer as an absolute time.
Chris@16 107 time_type expires_at(const implementation_type& impl) const
Chris@16 108 {
Chris@16 109 return service_impl_.expires_at(impl);
Chris@16 110 }
Chris@16 111
Chris@16 112 /// Set the expiry time for the timer as an absolute time.
Chris@16 113 std::size_t expires_at(implementation_type& impl,
Chris@16 114 const time_type& expiry_time, boost::system::error_code& ec)
Chris@16 115 {
Chris@16 116 return service_impl_.expires_at(impl, expiry_time, ec);
Chris@16 117 }
Chris@16 118
Chris@16 119 /// Get the expiry time for the timer relative to now.
Chris@16 120 duration_type expires_from_now(const implementation_type& impl) const
Chris@16 121 {
Chris@16 122 return service_impl_.expires_from_now(impl);
Chris@16 123 }
Chris@16 124
Chris@16 125 /// Set the expiry time for the timer relative to now.
Chris@16 126 std::size_t expires_from_now(implementation_type& impl,
Chris@16 127 const duration_type& expiry_time, boost::system::error_code& ec)
Chris@16 128 {
Chris@16 129 return service_impl_.expires_from_now(impl, expiry_time, ec);
Chris@16 130 }
Chris@16 131
Chris@16 132 // Perform a blocking wait on the timer.
Chris@16 133 void wait(implementation_type& impl, boost::system::error_code& ec)
Chris@16 134 {
Chris@16 135 service_impl_.wait(impl, ec);
Chris@16 136 }
Chris@16 137
Chris@16 138 // Start an asynchronous wait on the timer.
Chris@16 139 template <typename WaitHandler>
Chris@16 140 BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
Chris@16 141 void (boost::system::error_code))
Chris@16 142 async_wait(implementation_type& impl,
Chris@16 143 BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
Chris@16 144 {
Chris@16 145 detail::async_result_init<
Chris@16 146 WaitHandler, void (boost::system::error_code)> init(
Chris@16 147 BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
Chris@16 148
Chris@16 149 service_impl_.async_wait(impl, init.handler);
Chris@16 150
Chris@16 151 return init.result.get();
Chris@16 152 }
Chris@16 153
Chris@16 154 private:
Chris@16 155 // Destroy all user-defined handler objects owned by the service.
Chris@16 156 void shutdown_service()
Chris@16 157 {
Chris@16 158 service_impl_.shutdown_service();
Chris@16 159 }
Chris@16 160
Chris@16 161 // The platform-specific implementation.
Chris@16 162 service_impl_type service_impl_;
Chris@16 163 };
Chris@16 164
Chris@16 165 } // namespace asio
Chris@16 166 } // namespace boost
Chris@16 167
Chris@16 168 #include <boost/asio/detail/pop_options.hpp>
Chris@16 169
Chris@16 170 #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
Chris@16 171 // || defined(GENERATING_DOCUMENTATION)
Chris@16 172
Chris@16 173 #endif // BOOST_ASIO_DEADLINE_TIMER_SERVICE_HPP