Realistic 3D camera system
3D camera system components
io_service.hpp
Go to the documentation of this file.
1 //
2 // impl/io_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_IMPL_IO_SERVICE_HPP
12 #define ASIO_IMPL_IO_SERVICE_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
20 
22 
23 namespace asio {
24 
25 template <typename Service>
26 inline Service& use_service(io_service& ios)
27 {
28  // Check that Service meets the necessary type requirements.
29  (void)static_cast<io_service::service*>(static_cast<Service*>(0));
30  (void)static_cast<const io_service::id*>(&Service::id);
31 
32  return ios.service_registry_->template use_service<Service>();
33 }
34 
35 template <>
36 inline detail::io_service_impl& use_service<detail::io_service_impl>(
37  io_service& ios)
38 {
39  return ios.impl_;
40 }
41 
42 template <typename Service>
43 inline void add_service(io_service& ios, Service* svc)
44 {
45  // Check that Service meets the necessary type requirements.
46  (void)static_cast<io_service::service*>(static_cast<Service*>(0));
47  (void)static_cast<const io_service::id*>(&Service::id);
48 
49  ios.service_registry_->template add_service<Service>(svc);
50 }
51 
52 template <typename Service>
53 inline bool has_service(io_service& ios)
54 {
55  // Check that Service meets the necessary type requirements.
56  (void)static_cast<io_service::service*>(static_cast<Service*>(0));
57  (void)static_cast<const io_service::id*>(&Service::id);
58 
59  return ios.service_registry_->template has_service<Service>();
60 }
61 
62 } // namespace asio
63 
65 
66 #if defined(ASIO_HAS_IOCP)
68 #else
70 #endif
71 
73 
74 namespace asio {
75 
76 template <typename CompletionHandler>
77 inline ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
78 io_service::dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
79 {
80  // If you get an error on the following line it means that your handler does
81  // not meet the documented type requirements for a CompletionHandler.
82  ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
83 
85  CompletionHandler, void ()> init(
86  ASIO_MOVE_CAST(CompletionHandler)(handler));
87 
88  impl_.dispatch(init.handler);
89 
90  return init.result.get();
91 }
92 
93 template <typename CompletionHandler>
94 inline ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
95 io_service::post(ASIO_MOVE_ARG(CompletionHandler) handler)
96 {
97  // If you get an error on the following line it means that your handler does
98  // not meet the documented type requirements for a CompletionHandler.
99  ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
100 
102  CompletionHandler, void ()> init(
103  ASIO_MOVE_CAST(CompletionHandler)(handler));
104 
105  impl_.post(init.handler);
106 
107  return init.result.get();
108 }
109 
110 template <typename Handler>
111 #if defined(GENERATING_DOCUMENTATION)
112 unspecified
113 #else
115 #endif
116 io_service::wrap(Handler handler)
117 {
118  return detail::wrapped_handler<io_service&, Handler>(*this, handler);
119 }
120 
122  : io_service_impl_(io_service.impl_)
123 {
124  io_service_impl_.work_started();
125 }
126 
127 inline io_service::work::work(const work& other)
128  : io_service_impl_(other.io_service_impl_)
129 {
130  io_service_impl_.work_started();
131 }
132 
134 {
135  io_service_impl_.work_finished();
136 }
137 
139 {
140  return io_service_impl_.get_io_service();
141 }
142 
144 {
145  return owner_;
146 }
147 
148 } // namespace asio
149 
151 
152 #endif // ASIO_IMPL_IO_SERVICE_HPP
Provides core I/O functionality.
Definition: io_service.hpp:184
post(ASIO_MOVE_ARG(CompletionHandler) handler)
Request the io_service to invoke the given handler and return immediately.
Class to inform the io_service when it has work to do.
Definition: io_service.hpp:626
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))
Service & use_service(io_service &ios)
Definition: io_service.hpp:26
asio::io_service & get_io_service()
Get the io_service object that owns the service.
Definition: io_service.hpp:143
class task_io_service io_service_impl
Definition: io_service.hpp:48
~work()
Destructor notifies the io_service that the work is complete.
Definition: io_service.hpp:133
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
asio::io_service & get_io_service()
Get the io_service associated with the work.
Definition: io_service.hpp:138
void add_service(io_service &ios, Service *svc)
Definition: io_service.hpp:43
detail::wrapped_handler< io_service &, Handler > wrap(Handler handler)
Definition: io_service.hpp:116
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Definition: read.hpp:704
work(asio::io_service &io_service)
Constructor notifies the io_service that work is starting.
Definition: io_service.hpp:121
bool has_service(io_service &ios)
Definition: io_service.hpp:53
handler_type< Handler, Signature >::type handler
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
#define ASIO_COMPLETION_HANDLER_CHECK(handler_type, handler)
async_result< typename handler_type< Handler, Signature >::type > result