1 #ifndef IO_URING_ENGINE_H
2 #define IO_URING_ENGINE_H 1
8 #include <sys/socket.h>
18 IOUringEngine(size_t slop_bytes);
19 void submit_read(int fd, size_t len, off_t offset, std::function<void(std::string_view)> cb);
21 size_t get_waiting_reads() const { return pending_reads + queued_reads.size(); }
25 void submit_read_internal(io_uring_sqe *sqe, int fd, size_t len, off_t offset, std::function<void(std::string_view)> cb);
29 size_t pending_reads = 0; // Number of requests we have going in the ring.
31 const size_t slop_bytes;
37 std::function<void(std::string_view)> cb;
39 std::queue<QueuedRead> queued_reads;
44 std::function<void(std::string_view)> cb;
52 // 256 simultaneous requests should be ample, for slow and fast media alike.
53 static constexpr size_t queue_depth = 256;
56 // A wrapper around pread() that returns an incomplete read.
57 // Always synchronous (no io_uring).
58 void complete_pread(int fd, void *ptr, size_t len, off_t offset);
60 #endif // !defined(IO_URING_ENGINE_H)