File indexing completed on 2025-09-17 08:23:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_IMPL_IO_CONTEXT_IPP
0012 #define BOOST_ASIO_IMPL_IO_CONTEXT_IPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/config.hpp>
0020 #include <boost/asio/io_context.hpp>
0021 #include <boost/asio/detail/concurrency_hint.hpp>
0022 #include <boost/asio/detail/limits.hpp>
0023 #include <boost/asio/detail/scoped_ptr.hpp>
0024 #include <boost/asio/detail/service_registry.hpp>
0025 #include <boost/asio/detail/throw_error.hpp>
0026
0027 #if defined(BOOST_ASIO_HAS_IOCP)
0028 # include <boost/asio/detail/win_iocp_io_context.hpp>
0029 #else
0030 # include <boost/asio/detail/scheduler.hpp>
0031 #endif
0032
0033 #include <boost/asio/detail/push_options.hpp>
0034
0035 namespace boost {
0036 namespace asio {
0037
0038 io_context::io_context()
0039 : execution_context(config_from_concurrency_hint()),
0040 impl_(add_impl(new impl_type(*this, false)))
0041 {
0042 }
0043
0044 io_context::io_context(int concurrency_hint)
0045 : execution_context(config_from_concurrency_hint(concurrency_hint)),
0046 impl_(add_impl(new impl_type(*this, false)))
0047 {
0048 }
0049
0050 io_context::io_context(const execution_context::service_maker& initial_services)
0051 : execution_context(initial_services),
0052 impl_(add_impl(new impl_type(*this, false)))
0053 {
0054 }
0055
0056 io_context::impl_type& io_context::add_impl(io_context::impl_type* impl)
0057 {
0058 boost::asio::detail::scoped_ptr<impl_type> scoped_impl(impl);
0059 boost::asio::add_service<impl_type>(*this, scoped_impl.get());
0060 return *scoped_impl.release();
0061 }
0062
0063 io_context::~io_context()
0064 {
0065 shutdown();
0066 }
0067
0068 io_context::count_type io_context::run()
0069 {
0070 boost::system::error_code ec;
0071 count_type s = impl_.run(ec);
0072 boost::asio::detail::throw_error(ec);
0073 return s;
0074 }
0075
0076 io_context::count_type io_context::run_one()
0077 {
0078 boost::system::error_code ec;
0079 count_type s = impl_.run_one(ec);
0080 boost::asio::detail::throw_error(ec);
0081 return s;
0082 }
0083
0084 io_context::count_type io_context::poll()
0085 {
0086 boost::system::error_code ec;
0087 count_type s = impl_.poll(ec);
0088 boost::asio::detail::throw_error(ec);
0089 return s;
0090 }
0091
0092 io_context::count_type io_context::poll_one()
0093 {
0094 boost::system::error_code ec;
0095 count_type s = impl_.poll_one(ec);
0096 boost::asio::detail::throw_error(ec);
0097 return s;
0098 }
0099
0100 void io_context::stop()
0101 {
0102 impl_.stop();
0103 }
0104
0105 bool io_context::stopped() const
0106 {
0107 return impl_.stopped();
0108 }
0109
0110 void io_context::restart()
0111 {
0112 impl_.restart();
0113 }
0114
0115 io_context::service::service(boost::asio::io_context& owner)
0116 : execution_context::service(owner)
0117 {
0118 }
0119
0120 io_context::service::~service()
0121 {
0122 }
0123
0124 void io_context::service::shutdown()
0125 {
0126 }
0127
0128 void io_context::service::notify_fork(io_context::fork_event)
0129 {
0130 }
0131
0132 }
0133 }
0134
0135 #include <boost/asio/detail/pop_options.hpp>
0136
0137 #endif