Skip to content

Commit

Permalink
io/uring/Ring: add more API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Nov 11, 2024
1 parent 84e3501 commit 370df37
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/io/uring/Ring.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down

0 comments on commit 370df37

Please sign in to comment.