Realistic 3D camera system
3D camera system components
deadline_timer_service.hpp
Go to the documentation of this file.
1 //
2 // deadline_timer_service.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 
11 #ifndef ASIO_DEADLINE_TIMER_SERVICE_HPP
12 #define ASIO_DEADLINE_TIMER_SERVICE_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
20 #if defined(ASIO_HAS_BOOST_DATE_TIME) \
21  || defined(GENERATING_DOCUMENTATION)
22 
23 #include <cstddef>
24 #include "asio/async_result.hpp"
26 #include "asio/io_service.hpp"
27 #include "asio/time_traits.hpp"
29 
31 
32 namespace asio {
33 
35 template <typename TimeType,
36  typename TimeTraits = asio::time_traits<TimeType> >
37 class deadline_timer_service
38 #if defined(GENERATING_DOCUMENTATION)
40 #else
42  deadline_timer_service<TimeType, TimeTraits> >
43 #endif
44 {
45 public:
46 #if defined(GENERATING_DOCUMENTATION)
47  static asio::io_service::id id;
49 #endif
50 
52  typedef TimeTraits traits_type;
53 
55  typedef typename traits_type::time_type time_type;
56 
58  typedef typename traits_type::duration_type duration_type;
59 
60 private:
61  // The type of the platform-specific implementation.
62  typedef detail::deadline_timer_service<traits_type> service_impl_type;
63 
64 public:
66 #if defined(GENERATING_DOCUMENTATION)
67  typedef implementation_defined implementation_type;
68 #else
69  typedef typename service_impl_type::implementation_type implementation_type;
70 #endif
71 
73  explicit deadline_timer_service(asio::io_service& io_service)
74  : asio::detail::service_base<
75  deadline_timer_service<TimeType, TimeTraits> >(io_service),
76  service_impl_(io_service)
77  {
78  }
79 
81  void construct(implementation_type& impl)
82  {
83  service_impl_.construct(impl);
84  }
85 
87  void destroy(implementation_type& impl)
88  {
89  service_impl_.destroy(impl);
90  }
91 
93  std::size_t cancel(implementation_type& impl, asio::error_code& ec)
94  {
95  return service_impl_.cancel(impl, ec);
96  }
97 
99  std::size_t cancel_one(implementation_type& impl,
100  asio::error_code& ec)
101  {
102  return service_impl_.cancel_one(impl, ec);
103  }
104 
106  time_type expires_at(const implementation_type& impl) const
107  {
108  return service_impl_.expires_at(impl);
109  }
110 
112  std::size_t expires_at(implementation_type& impl,
113  const time_type& expiry_time, asio::error_code& ec)
114  {
115  return service_impl_.expires_at(impl, expiry_time, ec);
116  }
117 
119  duration_type expires_from_now(const implementation_type& impl) const
120  {
121  return service_impl_.expires_from_now(impl);
122  }
123 
125  std::size_t expires_from_now(implementation_type& impl,
126  const duration_type& expiry_time, asio::error_code& ec)
127  {
128  return service_impl_.expires_from_now(impl, expiry_time, ec);
129  }
130 
131  // Perform a blocking wait on the timer.
132  void wait(implementation_type& impl, asio::error_code& ec)
133  {
134  service_impl_.wait(impl, ec);
135  }
136 
137  // Start an asynchronous wait on the timer.
138  template <typename WaitHandler>
139  ASIO_INITFN_RESULT_TYPE(WaitHandler,
140  void (asio::error_code))
141  async_wait(implementation_type& impl,
142  ASIO_MOVE_ARG(WaitHandler) handler)
143  {
144  detail::async_result_init<
145  WaitHandler, void (asio::error_code)> init(
146  ASIO_MOVE_CAST(WaitHandler)(handler));
147 
148  service_impl_.async_wait(impl, init.handler);
149 
150  return init.result.get();
151  }
152 
153 private:
154  // Destroy all user-defined handler objects owned by the service.
155  void shutdown_service()
156  {
157  service_impl_.shutdown_service();
158  }
159 
160  // The platform-specific implementation.
161  service_impl_type service_impl_;
162 };
163 
164 } // namespace asio
165 
167 
168 #endif // defined(ASIO_HAS_BOOST_DATE_TIME)
169  // || defined(GENERATING_DOCUMENTATION)
170 
171 #endif // ASIO_DEADLINE_TIMER_SERVICE_HPP
Class used to uniquely identify a service.
Definition: io_service.hpp:665
Provides core I/O functionality.
Definition: io_service.hpp:184
asio::basic_streambuf< Allocator > MatchCondition enable_if< is_match_condition< MatchCondition >::value >::type *detail::async_result_init< ReadHandler, void(asio::error_code, std::size_t)> init(ASIO_MOVE_CAST(ReadHandler)(handler))
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Definition: read.hpp:704
Class to represent an error code value.
Definition: error_code.hpp:80
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
Base class for all io_service services.
Definition: io_service.hpp:674