File indexing completed on 2025-01-18 09:28:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_REACTIVE_NULL_BUFFERS_OP_HPP
0012 #define BOOST_ASIO_DETAIL_REACTIVE_NULL_BUFFERS_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 #include <boost/asio/detail/bind_handler.hpp>
0020 #include <boost/asio/detail/fenced_block.hpp>
0021 #include <boost/asio/detail/handler_alloc_helpers.hpp>
0022 #include <boost/asio/detail/handler_work.hpp>
0023 #include <boost/asio/detail/memory.hpp>
0024 #include <boost/asio/detail/reactor_op.hpp>
0025
0026 #include <boost/asio/detail/push_options.hpp>
0027
0028 namespace boost {
0029 namespace asio {
0030 namespace detail {
0031
0032 template <typename Handler, typename IoExecutor>
0033 class reactive_null_buffers_op : public reactor_op
0034 {
0035 public:
0036 typedef Handler handler_type;
0037 typedef IoExecutor io_executor_type;
0038
0039 BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_null_buffers_op);
0040
0041 reactive_null_buffers_op(const boost::system::error_code& success_ec,
0042 Handler& handler, const IoExecutor& io_ex)
0043 : reactor_op(success_ec, &reactive_null_buffers_op::do_perform,
0044 &reactive_null_buffers_op::do_complete),
0045 handler_(static_cast<Handler&&>(handler)),
0046 work_(handler_, io_ex)
0047 {
0048 }
0049
0050 static status do_perform(reactor_op*)
0051 {
0052 return done;
0053 }
0054
0055 static void do_complete(void* owner, operation* base,
0056 const boost::system::error_code& ,
0057 std::size_t )
0058 {
0059
0060 BOOST_ASIO_ASSUME(base != 0);
0061 reactive_null_buffers_op* o(static_cast<reactive_null_buffers_op*>(base));
0062 ptr p = { boost::asio::detail::addressof(o->handler_), o, o };
0063
0064 BOOST_ASIO_HANDLER_COMPLETION((*o));
0065
0066
0067 handler_work<Handler, IoExecutor> w(
0068 static_cast<handler_work<Handler, IoExecutor>&&>(
0069 o->work_));
0070
0071
0072
0073
0074
0075
0076
0077 detail::binder2<Handler, boost::system::error_code, std::size_t>
0078 handler(o->handler_, o->ec_, o->bytes_transferred_);
0079 p.h = boost::asio::detail::addressof(handler.handler_);
0080 p.reset();
0081
0082
0083 if (owner)
0084 {
0085 fenced_block b(fenced_block::half);
0086 BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_));
0087 w.complete(handler, handler.handler_);
0088 BOOST_ASIO_HANDLER_INVOCATION_END;
0089 }
0090 }
0091
0092 static void do_immediate(operation* base, bool, const void* io_ex)
0093 {
0094
0095 BOOST_ASIO_ASSUME(base != 0);
0096 reactive_null_buffers_op* o(static_cast<reactive_null_buffers_op*>(base));
0097 ptr p = { boost::asio::detail::addressof(o->handler_), o, o };
0098
0099 BOOST_ASIO_HANDLER_COMPLETION((*o));
0100
0101
0102 immediate_handler_work<Handler, IoExecutor> w(
0103 static_cast<handler_work<Handler, IoExecutor>&&>(
0104 o->work_));
0105
0106
0107
0108
0109
0110
0111
0112 detail::binder2<Handler, boost::system::error_code, std::size_t>
0113 handler(o->handler_, o->ec_, o->bytes_transferred_);
0114 p.h = boost::asio::detail::addressof(handler.handler_);
0115 p.reset();
0116
0117 BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_));
0118 w.complete(handler, handler.handler_, io_ex);
0119 BOOST_ASIO_HANDLER_INVOCATION_END;
0120 }
0121
0122 private:
0123 Handler handler_;
0124 handler_work<Handler, IoExecutor> work_;
0125 };
0126
0127 }
0128 }
0129 }
0130
0131 #include <boost/asio/detail/pop_options.hpp>
0132
0133 #endif