Realistic 3D camera system
3D camera system components
strand.hpp
Go to the documentation of this file.
1 //
2 // strand.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_STRAND_HPP
12 #define ASIO_STRAND_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 #include "asio/async_result.hpp"
23 #include "asio/io_service.hpp"
24 
26 
27 namespace asio {
28 
30 
86 {
87 public:
89 
96  : service_(asio::use_service<
97  asio::detail::strand_service>(io_service))
98  {
99  service_.construct(impl_);
100  }
101 
103 
110  {
111  }
112 
114 
122  {
123  return service_.get_io_service();
124  }
125 
127 
145  template <typename CompletionHandler>
146  ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
147  dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
148  {
149  // If you get an error on the following line it means that your handler does
150  // not meet the documented type requirements for a CompletionHandler.
151  ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
152 
154  CompletionHandler, void ()> init(
155  ASIO_MOVE_CAST(CompletionHandler)(handler));
156 
157  service_.dispatch(impl_, init.handler);
158 
159  return init.result.get();
160  }
161 
164 
178  template <typename CompletionHandler>
179  ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
180  post(ASIO_MOVE_ARG(CompletionHandler) handler)
181  {
182  // If you get an error on the following line it means that your handler does
183  // not meet the documented type requirements for a CompletionHandler.
184  ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
185 
187  CompletionHandler, void ()> init(
188  ASIO_MOVE_CAST(CompletionHandler)(handler));
189 
190  service_.post(impl_, init.handler);
191 
192  return init.result.get();
193  }
194 
197 
216  template <typename Handler>
217 #if defined(GENERATING_DOCUMENTATION)
218  unspecified
219 #else
221 #endif
222  wrap(Handler handler)
223  {
225  detail::is_continuation_if_running>(*this, handler);
226  }
227 
229 
235  {
236  return service_.running_in_this_thread(impl_);
237  }
238 
239 private:
242 };
243 
247 
248 } // namespace asio
249 
251 
252 #endif // ASIO_STRAND_HPP
~strand()
Destructor.
Definition: strand.hpp:109
post(ASIO_MOVE_ARG(CompletionHandler) handler)
Definition: strand.hpp:180
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))
void post(implementation_type &impl, Handler &handler)
Provides serialised handler execution.
Definition: strand.hpp:85
ASIO_DECL void construct(implementation_type &impl)
asio::io_service & get_io_service()
Get the io_service object that owns the service.
Definition: io_service.hpp:143
void dispatch(implementation_type &impl, Handler &handler)
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
asio::io_service::strand strand
Definition: strand.hpp:246
ASIO_DECL bool running_in_this_thread(const implementation_type &impl) const
strand(asio::io_service &io_service)
Constructor.
Definition: strand.hpp:95
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Definition: read.hpp:704
bool running_in_this_thread() const
Determine whether the strand is running in the current thread.
Definition: strand.hpp:234
detail::wrapped_handler< strand, Handler, detail::is_continuation_if_running > wrap(Handler handler)
Definition: strand.hpp:222
dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
Request the strand to invoke the given handler.
Definition: strand.hpp:147
friend Service & use_service(io_service &ios)
Obtain the service object corresponding to the given type.
Definition: io_service.hpp:26
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
asio::io_service & get_io_service()
Get the io_service associated with the strand.
Definition: strand.hpp:121