io/uring/Ring: add more API documentation

This commit is contained in:
Max Kellermann 2024-11-11 17:44:09 +01:00 committed by Max Kellermann
parent 84e3501084
commit 370df37596
1 changed files with 32 additions and 0 deletions

View File

@ -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);
}