File indexing completed on 2025-01-18 09:28:55
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/io_context.hpp>
0020 #include <boost/asio/detail/concurrency_hint.hpp>
0021 #include <boost/asio/detail/limits.hpp>
0022 #include <boost/asio/detail/scoped_ptr.hpp>
0023 #include <boost/asio/detail/service_registry.hpp>
0024 #include <boost/asio/detail/throw_error.hpp>
0025
0026 #if defined(BOOST_ASIO_HAS_IOCP)
0027 # include <boost/asio/detail/win_iocp_io_context.hpp>
0028 #else
0029 # include <boost/asio/detail/scheduler.hpp>
0030 #endif
0031
0032 #include <boost/asio/detail/push_options.hpp>
0033
0034 namespace boost {
0035 namespace asio {
0036
0037 io_context::io_context()
0038 : impl_(add_impl(new impl_type(*this,
0039 BOOST_ASIO_CONCURRENCY_HINT_DEFAULT, false)))
0040 {
0041 }
0042
0043 io_context::io_context(int concurrency_hint)
0044 : impl_(add_impl(new impl_type(*this, concurrency_hint == 1
0045 ? BOOST_ASIO_CONCURRENCY_HINT_1 : concurrency_hint, false)))
0046 {
0047 }
0048
0049 io_context::impl_type& io_context::add_impl(io_context::impl_type* impl)
0050 {
0051 boost::asio::detail::scoped_ptr<impl_type> scoped_impl(impl);
0052 boost::asio::add_service<impl_type>(*this, scoped_impl.get());
0053 return *scoped_impl.release();
0054 }
0055
0056 io_context::~io_context()
0057 {
0058 shutdown();
0059 }
0060
0061 io_context::count_type io_context::run()
0062 {
0063 boost::system::error_code ec;
0064 count_type s = impl_.run(ec);
0065 boost::asio::detail::throw_error(ec);
0066 return s;
0067 }
0068
0069 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0070 io_context::count_type io_context::run(boost::system::error_code& ec)
0071 {
0072 return impl_.run(ec);
0073 }
0074 #endif
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 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0085 io_context::count_type io_context::run_one(boost::system::error_code& ec)
0086 {
0087 return impl_.run_one(ec);
0088 }
0089 #endif
0090
0091 io_context::count_type io_context::poll()
0092 {
0093 boost::system::error_code ec;
0094 count_type s = impl_.poll(ec);
0095 boost::asio::detail::throw_error(ec);
0096 return s;
0097 }
0098
0099 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0100 io_context::count_type io_context::poll(boost::system::error_code& ec)
0101 {
0102 return impl_.poll(ec);
0103 }
0104 #endif
0105
0106 io_context::count_type io_context::poll_one()
0107 {
0108 boost::system::error_code ec;
0109 count_type s = impl_.poll_one(ec);
0110 boost::asio::detail::throw_error(ec);
0111 return s;
0112 }
0113
0114 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0115 io_context::count_type io_context::poll_one(boost::system::error_code& ec)
0116 {
0117 return impl_.poll_one(ec);
0118 }
0119 #endif
0120
0121 void io_context::stop()
0122 {
0123 impl_.stop();
0124 }
0125
0126 bool io_context::stopped() const
0127 {
0128 return impl_.stopped();
0129 }
0130
0131 void io_context::restart()
0132 {
0133 impl_.restart();
0134 }
0135
0136 io_context::service::service(boost::asio::io_context& owner)
0137 : execution_context::service(owner)
0138 {
0139 }
0140
0141 io_context::service::~service()
0142 {
0143 }
0144
0145 void io_context::service::shutdown()
0146 {
0147 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0148 shutdown_service();
0149 #endif
0150 }
0151
0152 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0153 void io_context::service::shutdown_service()
0154 {
0155 }
0156 #endif
0157
0158 void io_context::service::notify_fork(io_context::fork_event ev)
0159 {
0160 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0161 fork_service(ev);
0162 #else
0163 (void)ev;
0164 #endif
0165 }
0166
0167 #if !defined(BOOST_ASIO_NO_DEPRECATED)
0168 void io_context::service::fork_service(io_context::fork_event)
0169 {
0170 }
0171 #endif
0172
0173 }
0174 }
0175
0176 #include <boost/asio/detail/pop_options.hpp>
0177
0178 #endif