2 // detail/io_uring_operation.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_DETAIL_IO_URING_OPERATION_HPP
12 #define BOOST_ASIO_DETAIL_IO_URING_OPERATION_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(BOOST_ASIO_HAS_IO_URING)
23 #include <boost/asio/detail/cstdint.hpp>
24 #include <boost/asio/detail/operation.hpp>
26 #include <boost/asio/detail/push_options.hpp>
32 class io_uring_operation
36 // The error code to be passed to the completion handler.
37 boost::system::error_code ec_;
39 // The number of bytes transferred, to be passed to the completion handler.
40 std::size_t bytes_transferred_;
42 // The operation key used for targeted cancellation.
43 void* cancellation_key_;
45 // Prepare the operation.
46 void prepare(::io_uring_sqe* sqe)
48 return prepare_func_(this, sqe);
51 // Perform actions associated with the operation. Returns true when complete.
52 bool perform(bool after_completion)
54 return perform_func_(this, after_completion);
58 typedef void (*prepare_func_type)(io_uring_operation*, ::io_uring_sqe*);
59 typedef bool (*perform_func_type)(io_uring_operation*, bool);
61 io_uring_operation(const boost::system::error_code& success_ec,
62 prepare_func_type prepare_func, perform_func_type perform_func,
63 func_type complete_func)
64 : operation(complete_func),
66 bytes_transferred_(0),
68 prepare_func_(prepare_func),
69 perform_func_(perform_func)
74 prepare_func_type prepare_func_;
75 perform_func_type perform_func_;
82 #include <boost/asio/detail/pop_options.hpp>
84 #endif // defined(BOOST_ASIO_HAS_IO_URING)
86 #endif // BOOST_ASIO_DETAIL_IO_URING_OPERATION_HPP