]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/detail/io_uring_operation.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / detail / io_uring_operation.hpp
1 //
2 // detail/io_uring_operation.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10
11 #ifndef BOOST_ASIO_DETAIL_IO_URING_OPERATION_HPP
12 #define BOOST_ASIO_DETAIL_IO_URING_OPERATION_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19
20 #if defined(BOOST_ASIO_HAS_IO_URING)
21
22 #include <liburing.h>
23 #include <boost/asio/detail/cstdint.hpp>
24 #include <boost/asio/detail/operation.hpp>
25
26 #include <boost/asio/detail/push_options.hpp>
27
28 namespace boost {
29 namespace asio {
30 namespace detail {
31
32 class io_uring_operation
33 : public operation
34 {
35 public:
36 // The error code to be passed to the completion handler.
37 boost::system::error_code ec_;
38
39 // The number of bytes transferred, to be passed to the completion handler.
40 std::size_t bytes_transferred_;
41
42 // The operation key used for targeted cancellation.
43 void* cancellation_key_;
44
45 // Prepare the operation.
46 void prepare(::io_uring_sqe* sqe)
47 {
48 return prepare_func_(this, sqe);
49 }
50
51 // Perform actions associated with the operation. Returns true when complete.
52 bool perform(bool after_completion)
53 {
54 return perform_func_(this, after_completion);
55 }
56
57 protected:
58 typedef void (*prepare_func_type)(io_uring_operation*, ::io_uring_sqe*);
59 typedef bool (*perform_func_type)(io_uring_operation*, bool);
60
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),
65 ec_(success_ec),
66 bytes_transferred_(0),
67 cancellation_key_(0),
68 prepare_func_(prepare_func),
69 perform_func_(perform_func)
70 {
71 }
72
73 private:
74 prepare_func_type prepare_func_;
75 perform_func_type perform_func_;
76 };
77
78 } // namespace detail
79 } // namespace asio
80 } // namespace boost
81
82 #include <boost/asio/detail/pop_options.hpp>
83
84 #endif // defined(BOOST_ASIO_HAS_IO_URING)
85
86 #endif // BOOST_ASIO_DETAIL_IO_URING_OPERATION_HPP