Realistic 3D camera system
3D camera system components
basic_deadline_timer.hpp
Go to the documentation of this file.
1 //
2 // basic_deadline_timer.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_BASIC_DEADLINE_TIMER_HPP
12 #define ASIO_BASIC_DEADLINE_TIMER_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/basic_io_object.hpp"
28 #include "asio/error.hpp"
29 
31 
32 namespace asio {
33 
35 
122 template <typename Time,
123  typename TimeTraits = asio::time_traits<Time>,
124  typename TimerService = deadline_timer_service<Time, TimeTraits> >
125 class basic_deadline_timer
126  : public basic_io_object<TimerService>
127 {
128 public:
130  typedef TimeTraits traits_type;
131 
133  typedef typename traits_type::time_type time_type;
134 
136  typedef typename traits_type::duration_type duration_type;
137 
139 
147  explicit basic_deadline_timer(asio::io_service& io_service)
148  : basic_io_object<TimerService>(io_service)
149  {
150  }
151 
153 
162  basic_deadline_timer(asio::io_service& io_service,
163  const time_type& expiry_time)
164  : basic_io_object<TimerService>(io_service)
165  {
166  asio::error_code ec;
167  this->service.expires_at(this->implementation, expiry_time, ec);
168  asio::detail::throw_error(ec, "expires_at");
169  }
170 
172 
181  basic_deadline_timer(asio::io_service& io_service,
182  const duration_type& expiry_time)
183  : basic_io_object<TimerService>(io_service)
184  {
185  asio::error_code ec;
186  this->service.expires_from_now(this->implementation, expiry_time, ec);
187  asio::detail::throw_error(ec, "expires_from_now");
188  }
189 
191 
212  std::size_t cancel()
213  {
214  asio::error_code ec;
215  std::size_t s = this->service.cancel(this->implementation, ec);
216  asio::detail::throw_error(ec, "cancel");
217  return s;
218  }
219 
221 
242  std::size_t cancel(asio::error_code& ec)
243  {
244  return this->service.cancel(this->implementation, ec);
245  }
246 
248 
271  std::size_t cancel_one()
272  {
273  asio::error_code ec;
274  std::size_t s = this->service.cancel_one(this->implementation, ec);
275  asio::detail::throw_error(ec, "cancel_one");
276  return s;
277  }
278 
280 
303  std::size_t cancel_one(asio::error_code& ec)
304  {
305  return this->service.cancel_one(this->implementation, ec);
306  }
307 
309 
313  time_type expires_at() const
314  {
315  return this->service.expires_at(this->implementation);
316  }
317 
319 
340  std::size_t expires_at(const time_type& expiry_time)
341  {
342  asio::error_code ec;
343  std::size_t s = this->service.expires_at(
344  this->implementation, expiry_time, ec);
345  asio::detail::throw_error(ec, "expires_at");
346  return s;
347  }
348 
350 
371  std::size_t expires_at(const time_type& expiry_time,
372  asio::error_code& ec)
373  {
374  return this->service.expires_at(this->implementation, expiry_time, ec);
375  }
376 
378 
382  duration_type expires_from_now() const
383  {
384  return this->service.expires_from_now(this->implementation);
385  }
386 
388 
409  std::size_t expires_from_now(const duration_type& expiry_time)
410  {
411  asio::error_code ec;
412  std::size_t s = this->service.expires_from_now(
413  this->implementation, expiry_time, ec);
414  asio::detail::throw_error(ec, "expires_from_now");
415  return s;
416  }
417 
419 
440  std::size_t expires_from_now(const duration_type& expiry_time,
441  asio::error_code& ec)
442  {
443  return this->service.expires_from_now(
444  this->implementation, expiry_time, ec);
445  }
446 
448 
454  void wait()
455  {
456  asio::error_code ec;
457  this->service.wait(this->implementation, ec);
458  asio::detail::throw_error(ec, "wait");
459  }
460 
462 
468  void wait(asio::error_code& ec)
469  {
470  this->service.wait(this->implementation, ec);
471  }
472 
474 
497  template <typename WaitHandler>
498  ASIO_INITFN_RESULT_TYPE(WaitHandler,
499  void (asio::error_code))
500  async_wait(ASIO_MOVE_ARG(WaitHandler) handler)
501  {
502  // If you get an error on the following line it means that your handler does
503  // not meet the documented type requirements for a WaitHandler.
504  ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
505 
506  return this->service.async_wait(this->implementation,
507  ASIO_MOVE_CAST(WaitHandler)(handler));
508  }
509 };
510 
511 } // namespace asio
512 
513 #include "asio/detail/pop_options.hpp"
514 
515 #endif // defined(ASIO_HAS_BOOST_DATE_TIME)
516  // || defined(GENERATING_DOCUMENTATION)
517 
518 #endif // ASIO_BASIC_DEADLINE_TIMER_HPP
void throw_error(const asio::error_code &err)
Definition: throw_error.hpp:31
Provides core I/O functionality.
Definition: io_service.hpp:184
SocketService & s
Definition: connect.hpp:521
#define ASIO_WAIT_HANDLER_CHECK(handler_type, 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