diff --git a/src/io/uring/Ring.hxx b/src/io/uring/Ring.hxx index 0cdeb1153..24ea3c6c6 100644 --- a/src/io/uring/Ring.hxx +++ b/src/io/uring/Ring.hxx @@ -19,6 +19,11 @@ class Ring { struct io_uring ring; public: + /** + * Construct the io_uring using io_uring_queue_init(). + * + * Throws on error. + */ Ring(unsigned entries, unsigned flags); ~Ring() noexcept { @@ -28,23 +33,50 @@ public: Ring(const Ring &) = delete; Ring &operator=(const Ring &) = delete; + /** + * Returns the io_uring file descriptor. + */ FileDescriptor GetFileDescriptor() const noexcept { return FileDescriptor(ring.ring_fd); } + /** + * Returns a submit queue entry or nullptr if the submit queue + * is full. + */ struct io_uring_sqe *GetSubmitEntry() noexcept { return io_uring_get_sqe(&ring); } + /** + * Submit all pending entries from the submit queue to the + * kernel using io_uring_submit(). + * + * Throws on error. + */ void Submit(); + /** + * Waits for one completion. + * + * Throws on error. + * + * @return a completion queue entry or nullptr on EAGAIN + */ struct io_uring_cqe *WaitCompletion(); /** + * Peek one completion (non-blocking). + * + * Throws on error. + * * @return a completion queue entry or nullptr on EAGAIN */ struct io_uring_cqe *PeekCompletion(); + /** + * Mark one completion event as consumed. + */ void SeenCompletion(struct io_uring_cqe &cqe) noexcept { io_uring_cqe_seen(&ring, &cqe); }