Realistic 3D camera system
3D camera system components
spawn.hpp
Go to the documentation of this file.
1 //
2 // spawn.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_SPAWN_HPP
12 #define ASIO_SPAWN_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 <boost/coroutine/all.hpp>
20 #include "asio/detail/weak_ptr.hpp"
22 #include "asio/io_service.hpp"
23 #include "asio/strand.hpp"
24 
26 
27 namespace asio {
28 
30 
47 template <typename Handler>
49 {
50 public:
52 
58 #if defined(GENERATING_DOCUMENTATION)
59  typedef implementation_defined callee_type;
60 #elif defined(BOOST_COROUTINES_UNIDIRECT) || defined(BOOST_COROUTINES_V2)
61  typedef boost::coroutines::push_coroutine<void> callee_type;
62 #else
63  typedef boost::coroutines::coroutine<void()> callee_type;
64 #endif
65 
67 
73 #if defined(GENERATING_DOCUMENTATION)
74  typedef implementation_defined caller_type;
75 #elif defined(BOOST_COROUTINES_UNIDIRECT) || defined(BOOST_COROUTINES_V2)
76  typedef boost::coroutines::pull_coroutine<void> caller_type;
77 #else
78  typedef boost::coroutines::coroutine<void()>::caller_type caller_type;
79 #endif
80 
82 
88  const detail::weak_ptr<callee_type>& coro,
89  caller_type& ca, Handler& handler)
90  : coro_(coro),
91  ca_(ca),
92  handler_(handler),
93  ec_(0)
94  {
95  }
96 
98 
117  {
118  basic_yield_context tmp(*this);
119  tmp.ec_ = &ec;
120  return tmp;
121  }
122 
123 #if defined(GENERATING_DOCUMENTATION)
124 private:
125 #endif // defined(GENERATING_DOCUMENTATION)
126  detail::weak_ptr<callee_type> coro_;
127  caller_type& ca_;
128  Handler& handler_;
130 };
131 
132 #if defined(GENERATING_DOCUMENTATION)
135 #else // defined(GENERATING_DOCUMENTATION)
136 typedef basic_yield_context<
138  io_service::strand, void(*)(),
140 #endif // defined(GENERATING_DOCUMENTATION)
141 
177 
180 
193 template <typename Handler, typename Function>
194 void spawn(ASIO_MOVE_ARG(Handler) handler,
195  ASIO_MOVE_ARG(Function) function,
196  const boost::coroutines::attributes& attributes
197  = boost::coroutines::attributes());
198 
200 
214 template <typename Handler, typename Function>
216  ASIO_MOVE_ARG(Function) function,
217  const boost::coroutines::attributes& attributes
218  = boost::coroutines::attributes());
219 
221 
233 template <typename Function>
235  ASIO_MOVE_ARG(Function) function,
236  const boost::coroutines::attributes& attributes
237  = boost::coroutines::attributes());
238 
240 
251 template <typename Function>
253  ASIO_MOVE_ARG(Function) function,
254  const boost::coroutines::attributes& attributes
255  = boost::coroutines::attributes());
256 
259 } // namespace asio
260 
262 
263 #include "asio/impl/spawn.hpp"
264 
265 #endif // ASIO_SPAWN_HPP
asio::error_code * ec_
Definition: spawn.hpp:129
Provides core I/O functionality.
Definition: io_service.hpp:184
Provides serialised handler execution.
Definition: strand.hpp:85
asio::io_service::strand strand
Definition: strand.hpp:246
basic_yield_context(const detail::weak_ptr< callee_type > &coro, caller_type &ca, Handler &handler)
Construct a yield context to represent the specified coroutine.
Definition: spawn.hpp:87
boost::coroutines::coroutine< void()> callee_type
The coroutine callee type, used by the implementation.
Definition: spawn.hpp:63
Context object the represents the currently executing coroutine.
Definition: spawn.hpp:48
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
void spawn(ASIO_MOVE_ARG(Handler) handler, ASIO_MOVE_ARG(Function) function, const boost::coroutines::attributes &attributes)
Definition: spawn.hpp:301
detail::weak_ptr< callee_type > coro_
Definition: spawn.hpp:126
basic_yield_context operator[](asio::error_code &ec) const
Return a yield context that sets the specified error_code.
Definition: spawn.hpp:116
caller_type & ca_
Definition: spawn.hpp:127
basic_yield_context< detail::wrapped_handler< io_service::strand, void(*)(), detail::is_continuation_if_running > > yield_context
Definition: spawn.hpp:139
boost::coroutines::coroutine< void()>::caller_type caller_type
The coroutine caller type, used by the implementation.
Definition: spawn.hpp:78