5 // Copyright (c) 2003-2016 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_SERVICE_IPP
12 #define BOOST_ASIO_IMPL_IO_SERVICE_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_service.hpp>
20 #include <boost/asio/detail/limits.hpp>
21 #include <boost/asio/detail/scoped_ptr.hpp>
22 #include <boost/asio/detail/service_registry.hpp>
23 #include <boost/asio/detail/throw_error.hpp>
25 #if defined(BOOST_ASIO_HAS_IOCP)
26 # include <boost/asio/detail/win_iocp_io_service.hpp>
28 # include <boost/asio/detail/task_io_service.hpp>
31 #include <boost/asio/detail/push_options.hpp>
36 io_service::io_service()
37 : service_registry_(new boost::asio::detail::service_registry(
38 *this, static_cast<impl_type*>(0),
39 (std::numeric_limits<std::size_t>::max)())),
40 impl_(service_registry_->first_service<impl_type>())
44 io_service::io_service(std::size_t concurrency_hint)
45 : service_registry_(new boost::asio::detail::service_registry(
46 *this, static_cast<impl_type*>(0), concurrency_hint)),
47 impl_(service_registry_->first_service<impl_type>())
51 io_service::~io_service()
53 delete service_registry_;
56 std::size_t io_service::run()
58 boost::system::error_code ec;
59 std::size_t s = impl_.run(ec);
60 boost::asio::detail::throw_error(ec);
64 std::size_t io_service::run(boost::system::error_code& ec)
69 std::size_t io_service::run_one()
71 boost::system::error_code ec;
72 std::size_t s = impl_.run_one(ec);
73 boost::asio::detail::throw_error(ec);
77 std::size_t io_service::run_one(boost::system::error_code& ec)
79 return impl_.run_one(ec);
82 std::size_t io_service::poll()
84 boost::system::error_code ec;
85 std::size_t s = impl_.poll(ec);
86 boost::asio::detail::throw_error(ec);
90 std::size_t io_service::poll(boost::system::error_code& ec)
92 return impl_.poll(ec);
95 std::size_t io_service::poll_one()
97 boost::system::error_code ec;
98 std::size_t s = impl_.poll_one(ec);
99 boost::asio::detail::throw_error(ec);
103 std::size_t io_service::poll_one(boost::system::error_code& ec)
105 return impl_.poll_one(ec);
108 void io_service::stop()
113 bool io_service::stopped() const
115 return impl_.stopped();
118 void io_service::reset()
123 void io_service::notify_fork(boost::asio::io_service::fork_event event)
125 service_registry_->notify_fork(event);
128 io_service::service::service(boost::asio::io_service& owner)
134 io_service::service::~service()
138 void io_service::service::fork_service(boost::asio::io_service::fork_event)
142 service_already_exists::service_already_exists()
143 : std::logic_error("Service already exists.")
147 invalid_service_owner::invalid_service_owner()
148 : std::logic_error("Invalid service owner.")
155 #include <boost/asio/detail/pop_options.hpp>
157 #endif // BOOST_ASIO_IMPL_IO_SERVICE_IPP