File indexing completed on 2025-01-18 09:28:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_OP_HPP
0012 #define BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_OP_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_HAS_IOCP)
0021
0022 #include <boost/asio/detail/bind_handler.hpp>
0023 #include <boost/asio/detail/fenced_block.hpp>
0024 #include <boost/asio/detail/handler_alloc_helpers.hpp>
0025 #include <boost/asio/detail/handler_work.hpp>
0026 #include <boost/asio/detail/memory.hpp>
0027 #include <boost/asio/detail/operation.hpp>
0028 #include <boost/asio/error.hpp>
0029
0030 #include <boost/asio/detail/push_options.hpp>
0031
0032 namespace boost {
0033 namespace asio {
0034 namespace detail {
0035
0036 template <typename Handler, typename IoExecutor>
0037 class win_iocp_overlapped_op : public operation
0038 {
0039 public:
0040 BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_overlapped_op);
0041
0042 win_iocp_overlapped_op(Handler& handler, const IoExecutor& io_ex)
0043 : operation(&win_iocp_overlapped_op::do_complete),
0044 handler_(static_cast<Handler&&>(handler)),
0045 work_(handler_, io_ex)
0046 {
0047 }
0048
0049 static void do_complete(void* owner, operation* base,
0050 const boost::system::error_code& result_ec, std::size_t bytes_transferred)
0051 {
0052 boost::system::error_code ec(result_ec);
0053
0054
0055 BOOST_ASIO_ASSUME(base != 0);
0056 win_iocp_overlapped_op* o(static_cast<win_iocp_overlapped_op*>(base));
0057 ptr p = { boost::asio::detail::addressof(o->handler_), o, o };
0058
0059 BOOST_ASIO_HANDLER_COMPLETION((*o));
0060
0061
0062 handler_work<Handler, IoExecutor> w(
0063 static_cast<handler_work<Handler, IoExecutor>&&>(
0064 o->work_));
0065
0066 BOOST_ASIO_ERROR_LOCATION(ec);
0067
0068
0069
0070
0071
0072
0073
0074 detail::binder2<Handler, boost::system::error_code, std::size_t>
0075 handler(o->handler_, ec, bytes_transferred);
0076 p.h = boost::asio::detail::addressof(handler.handler_);
0077 p.reset();
0078
0079
0080 if (owner)
0081 {
0082 fenced_block b(fenced_block::half);
0083 BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_));
0084 w.complete(handler, handler.handler_);
0085 BOOST_ASIO_HANDLER_INVOCATION_END;
0086 }
0087 }
0088
0089 private:
0090 Handler handler_;
0091 handler_work<Handler, IoExecutor> work_;
0092 };
0093
0094 }
0095 }
0096 }
0097
0098 #include <boost/asio/detail/pop_options.hpp>
0099
0100 #endif
0101
0102 #endif