File indexing completed on 2025-01-18 09:28:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_IO_URING_WAIT_OP_HPP
0012 #define BOOST_ASIO_DETAIL_IO_URING_WAIT_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/io_uring_operation.hpp>
0024 #include <boost/asio/detail/memory.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 io_uring_wait_op : public io_uring_operation
0034 {
0035 public:
0036 BOOST_ASIO_DEFINE_HANDLER_PTR(io_uring_wait_op);
0037
0038 io_uring_wait_op(const boost::system::error_code& success_ec, int descriptor,
0039 int poll_flags, Handler& handler, const IoExecutor& io_ex)
0040 : io_uring_operation(success_ec, &io_uring_wait_op::do_prepare,
0041 &io_uring_wait_op::do_perform, &io_uring_wait_op::do_complete),
0042 handler_(static_cast<Handler&&>(handler)),
0043 work_(handler_, io_ex),
0044 descriptor_(descriptor),
0045 poll_flags_(poll_flags)
0046 {
0047 }
0048
0049 static void do_prepare(io_uring_operation* base, ::io_uring_sqe* sqe)
0050 {
0051 BOOST_ASIO_ASSUME(base != 0);
0052 io_uring_wait_op* o(static_cast<io_uring_wait_op*>(base));
0053
0054 ::io_uring_prep_poll_add(sqe, o->descriptor_, o->poll_flags_);
0055 }
0056
0057 static bool do_perform(io_uring_operation*, bool after_completion)
0058 {
0059 return after_completion;
0060 }
0061
0062 static void do_complete(void* owner, operation* base,
0063 const boost::system::error_code& ,
0064 std::size_t )
0065 {
0066
0067 BOOST_ASIO_ASSUME(base != 0);
0068 io_uring_wait_op* o(static_cast<io_uring_wait_op*>(base));
0069 ptr p = { boost::asio::detail::addressof(o->handler_), o, o };
0070
0071 BOOST_ASIO_HANDLER_COMPLETION((*o));
0072
0073
0074 handler_work<Handler, IoExecutor> w(
0075 static_cast<handler_work<Handler, IoExecutor>&&>(
0076 o->work_));
0077
0078 BOOST_ASIO_ERROR_LOCATION(o->ec_);
0079
0080
0081
0082
0083
0084
0085
0086 detail::binder1<Handler, boost::system::error_code>
0087 handler(o->handler_, o->ec_);
0088 p.h = boost::asio::detail::addressof(handler.handler_);
0089 p.reset();
0090
0091
0092 if (owner)
0093 {
0094 fenced_block b(fenced_block::half);
0095 BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_));
0096 w.complete(handler, handler.handler_);
0097 BOOST_ASIO_HANDLER_INVOCATION_END;
0098 }
0099 }
0100
0101 private:
0102 Handler handler_;
0103 handler_work<Handler, IoExecutor> work_;
0104 int descriptor_;
0105 int poll_flags_;
0106 };
0107
0108 }
0109 }
0110 }
0111
0112 #include <boost/asio/detail/pop_options.hpp>
0113
0114 #endif