1 #ifndef IO_URING_ENGINE_H
2 #define IO_URING_ENGINE_H 1
11 #include <sys/socket.h>
16 void submit_read(int fd, size_t len, off_t offset, std::function<void(std::string)> cb);
18 size_t get_waiting_reads() const { return pending_reads + queued_reads.size(); }
22 void submit_read_internal(io_uring_sqe *sqe, int fd, size_t len, off_t offset, std::function<void(std::string)> cb);
26 size_t pending_reads = 0; // Number of requests we have going in the ring.
33 std::function<void(std::string)> cb;
35 std::queue<QueuedRead> queued_reads;
40 std::function<void(std::string)> cb;
48 // 256 simultaneous requests should be ample, for slow and fast media alike.
49 static constexpr size_t queue_depth = 256;
52 // A wrapper around pread() that returns an incomplete read.
53 // Always synchronous (no io_uring).
54 void complete_pread(int fd, void *ptr, size_t len, off_t offset);
56 #endif // !defined(IO_URING_ENGINE_H)