5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_IMPL_IO_CONTEXT_IPP
12 #define BOOST_ASIO_IMPL_IO_CONTEXT_IPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/io_context.hpp>
20 #include <boost/asio/detail/concurrency_hint.hpp>
21 #include <boost/asio/detail/limits.hpp>
22 #include <boost/asio/detail/scoped_ptr.hpp>
23 #include <boost/asio/detail/service_registry.hpp>
24 #include <boost/asio/detail/throw_error.hpp>
26 #if defined(BOOST_ASIO_HAS_IOCP)
27 # include <boost/asio/detail/win_iocp_io_context.hpp>
29 # include <boost/asio/detail/scheduler.hpp>
32 #include <boost/asio/detail/push_options.hpp>
37 io_context::io_context()
38 : impl_(add_impl(new impl_type(*this, BOOST_ASIO_CONCURRENCY_HINT_DEFAULT)))
42 io_context::io_context(int concurrency_hint)
43 : impl_(add_impl(new impl_type(*this, concurrency_hint == 1
44 ? BOOST_ASIO_CONCURRENCY_HINT_1 : concurrency_hint)))
48 io_context::impl_type& io_context::add_impl(io_context::impl_type* impl)
50 boost::asio::detail::scoped_ptr<impl_type> scoped_impl(impl);
51 boost::asio::add_service<impl_type>(*this, scoped_impl.get());
52 return *scoped_impl.release();
55 io_context::~io_context()
59 io_context::count_type io_context::run()
61 boost::system::error_code ec;
62 count_type s = impl_.run(ec);
63 boost::asio::detail::throw_error(ec);
67 #if !defined(BOOST_ASIO_NO_DEPRECATED)
68 io_context::count_type io_context::run(boost::system::error_code& ec)
72 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
74 io_context::count_type io_context::run_one()
76 boost::system::error_code ec;
77 count_type s = impl_.run_one(ec);
78 boost::asio::detail::throw_error(ec);
82 #if !defined(BOOST_ASIO_NO_DEPRECATED)
83 io_context::count_type io_context::run_one(boost::system::error_code& ec)
85 return impl_.run_one(ec);
87 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
89 io_context::count_type io_context::poll()
91 boost::system::error_code ec;
92 count_type s = impl_.poll(ec);
93 boost::asio::detail::throw_error(ec);
97 #if !defined(BOOST_ASIO_NO_DEPRECATED)
98 io_context::count_type io_context::poll(boost::system::error_code& ec)
100 return impl_.poll(ec);
102 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
104 io_context::count_type io_context::poll_one()
106 boost::system::error_code ec;
107 count_type s = impl_.poll_one(ec);
108 boost::asio::detail::throw_error(ec);
112 #if !defined(BOOST_ASIO_NO_DEPRECATED)
113 io_context::count_type io_context::poll_one(boost::system::error_code& ec)
115 return impl_.poll_one(ec);
117 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
119 void io_context::stop()
124 bool io_context::stopped() const
126 return impl_.stopped();
129 void io_context::restart()
134 io_context::service::service(boost::asio::io_context& owner)
135 : execution_context::service(owner)
139 io_context::service::~service()
143 void io_context::service::shutdown()
145 #if !defined(BOOST_ASIO_NO_DEPRECATED)
147 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
150 #if !defined(BOOST_ASIO_NO_DEPRECATED)
151 void io_context::service::shutdown_service()
154 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
156 void io_context::service::notify_fork(io_context::fork_event ev)
158 #if !defined(BOOST_ASIO_NO_DEPRECATED)
160 #else // !defined(BOOST_ASIO_NO_DEPRECATED)
162 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
165 #if !defined(BOOST_ASIO_NO_DEPRECATED)
166 void io_context::service::fork_service(io_context::fork_event)
169 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
174 #include <boost/asio/detail/pop_options.hpp>
176 #endif // BOOST_ASIO_IMPL_IO_CONTEXT_IPP