File indexing completed on 2025-01-18 09:28:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_IO_URING_FILE_SERVICE_HPP
0012 #define BOOST_ASIO_DETAIL_IO_URING_FILE_SERVICE_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_FILE) \
0021 && defined(BOOST_ASIO_HAS_IO_URING)
0022
0023 #include <string>
0024 #include <boost/asio/detail/cstdint.hpp>
0025 #include <boost/asio/detail/descriptor_ops.hpp>
0026 #include <boost/asio/detail/io_uring_descriptor_service.hpp>
0027 #include <boost/asio/error.hpp>
0028 #include <boost/asio/execution_context.hpp>
0029 #include <boost/asio/file_base.hpp>
0030
0031 #include <boost/asio/detail/push_options.hpp>
0032
0033 namespace boost {
0034 namespace asio {
0035 namespace detail {
0036
0037
0038 class io_uring_file_service :
0039 public execution_context_service_base<io_uring_file_service>
0040 {
0041 public:
0042 typedef io_uring_descriptor_service descriptor_service;
0043
0044
0045 typedef descriptor_service::native_handle_type native_handle_type;
0046
0047
0048 class implementation_type : descriptor_service::implementation_type
0049 {
0050 private:
0051
0052 friend class io_uring_file_service;
0053
0054 bool is_stream_;
0055 };
0056
0057 BOOST_ASIO_DECL io_uring_file_service(execution_context& context);
0058
0059
0060 BOOST_ASIO_DECL void shutdown();
0061
0062
0063 void construct(implementation_type& impl)
0064 {
0065 descriptor_service_.construct(impl);
0066 impl.is_stream_ = false;
0067 }
0068
0069
0070 void move_construct(implementation_type& impl,
0071 implementation_type& other_impl)
0072 {
0073 descriptor_service_.move_construct(impl, other_impl);
0074 impl.is_stream_ = other_impl.is_stream_;
0075 }
0076
0077
0078 void move_assign(implementation_type& impl,
0079 io_uring_file_service& other_service,
0080 implementation_type& other_impl)
0081 {
0082 descriptor_service_.move_assign(impl,
0083 other_service.descriptor_service_, other_impl);
0084 impl.is_stream_ = other_impl.is_stream_;
0085 }
0086
0087
0088 void destroy(implementation_type& impl)
0089 {
0090 descriptor_service_.destroy(impl);
0091 }
0092
0093
0094 BOOST_ASIO_DECL boost::system::error_code open(implementation_type& impl,
0095 const char* path, file_base::flags open_flags,
0096 boost::system::error_code& ec);
0097
0098
0099 boost::system::error_code assign(implementation_type& impl,
0100 const native_handle_type& native_descriptor,
0101 boost::system::error_code& ec)
0102 {
0103 return descriptor_service_.assign(impl, native_descriptor, ec);
0104 }
0105
0106
0107 void set_is_stream(implementation_type& impl, bool is_stream)
0108 {
0109 impl.is_stream_ = is_stream;
0110 }
0111
0112
0113 bool is_open(const implementation_type& impl) const
0114 {
0115 return descriptor_service_.is_open(impl);
0116 }
0117
0118
0119 boost::system::error_code close(implementation_type& impl,
0120 boost::system::error_code& ec)
0121 {
0122 return descriptor_service_.close(impl, ec);
0123 }
0124
0125
0126 native_handle_type native_handle(const implementation_type& impl) const
0127 {
0128 return descriptor_service_.native_handle(impl);
0129 }
0130
0131
0132 native_handle_type release(implementation_type& impl,
0133 boost::system::error_code& ec)
0134 {
0135 return descriptor_service_.release(impl, ec);
0136 }
0137
0138
0139 boost::system::error_code cancel(implementation_type& impl,
0140 boost::system::error_code& ec)
0141 {
0142 return descriptor_service_.cancel(impl, ec);
0143 }
0144
0145
0146 BOOST_ASIO_DECL uint64_t size(const implementation_type& impl,
0147 boost::system::error_code& ec) const;
0148
0149
0150 BOOST_ASIO_DECL boost::system::error_code resize(implementation_type& impl,
0151 uint64_t n, boost::system::error_code& ec);
0152
0153
0154 BOOST_ASIO_DECL boost::system::error_code sync_all(implementation_type& impl,
0155 boost::system::error_code& ec);
0156
0157
0158 BOOST_ASIO_DECL boost::system::error_code sync_data(implementation_type& impl,
0159 boost::system::error_code& ec);
0160
0161
0162 BOOST_ASIO_DECL uint64_t seek(implementation_type& impl, int64_t offset,
0163 file_base::seek_basis whence, boost::system::error_code& ec);
0164
0165
0166 template <typename ConstBufferSequence>
0167 size_t write_some(implementation_type& impl,
0168 const ConstBufferSequence& buffers, boost::system::error_code& ec)
0169 {
0170 return descriptor_service_.write_some(impl, buffers, ec);
0171 }
0172
0173
0174
0175 template <typename ConstBufferSequence, typename Handler, typename IoExecutor>
0176 void async_write_some(implementation_type& impl,
0177 const ConstBufferSequence& buffers,
0178 Handler& handler, const IoExecutor& io_ex)
0179 {
0180 descriptor_service_.async_write_some(impl, buffers, handler, io_ex);
0181 }
0182
0183
0184
0185 template <typename ConstBufferSequence>
0186 size_t write_some_at(implementation_type& impl, uint64_t offset,
0187 const ConstBufferSequence& buffers, boost::system::error_code& ec)
0188 {
0189 return descriptor_service_.write_some_at(impl, offset, buffers, ec);
0190 }
0191
0192
0193
0194 template <typename ConstBufferSequence, typename Handler, typename IoExecutor>
0195 void async_write_some_at(implementation_type& impl,
0196 uint64_t offset, const ConstBufferSequence& buffers,
0197 Handler& handler, const IoExecutor& io_ex)
0198 {
0199 descriptor_service_.async_write_some_at(
0200 impl, offset, buffers, handler, io_ex);
0201 }
0202
0203
0204 template <typename MutableBufferSequence>
0205 size_t read_some(implementation_type& impl,
0206 const MutableBufferSequence& buffers, boost::system::error_code& ec)
0207 {
0208 return descriptor_service_.read_some(impl, buffers, ec);
0209 }
0210
0211
0212
0213 template <typename MutableBufferSequence,
0214 typename Handler, typename IoExecutor>
0215 void async_read_some(implementation_type& impl,
0216 const MutableBufferSequence& buffers,
0217 Handler& handler, const IoExecutor& io_ex)
0218 {
0219 descriptor_service_.async_read_some(impl, buffers, handler, io_ex);
0220 }
0221
0222
0223 template <typename MutableBufferSequence>
0224 size_t read_some_at(implementation_type& impl, uint64_t offset,
0225 const MutableBufferSequence& buffers, boost::system::error_code& ec)
0226 {
0227 return descriptor_service_.read_some_at(impl, offset, buffers, ec);
0228 }
0229
0230
0231
0232 template <typename MutableBufferSequence,
0233 typename Handler, typename IoExecutor>
0234 void async_read_some_at(implementation_type& impl,
0235 uint64_t offset, const MutableBufferSequence& buffers,
0236 Handler& handler, const IoExecutor& io_ex)
0237 {
0238 descriptor_service_.async_read_some_at(
0239 impl, offset, buffers, handler, io_ex);
0240 }
0241
0242 private:
0243
0244 descriptor_service descriptor_service_;
0245
0246
0247 const boost::system::error_code success_ec_;
0248 };
0249
0250 }
0251 }
0252 }
0253
0254 #include <boost/asio/detail/pop_options.hpp>
0255
0256 #if defined(BOOST_ASIO_HEADER_ONLY)
0257 # include <boost/asio/detail/impl/io_uring_file_service.ipp>
0258 #endif
0259
0260 #endif
0261
0262
0263 #endif