io/uring/Ring: add more API documentation
This commit is contained in:
parent
84e3501084
commit
370df37596
|
@ -19,6 +19,11 @@ class Ring {
|
||||||
struct io_uring ring;
|
struct io_uring ring;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Construct the io_uring using io_uring_queue_init().
|
||||||
|
*
|
||||||
|
* Throws on error.
|
||||||
|
*/
|
||||||
Ring(unsigned entries, unsigned flags);
|
Ring(unsigned entries, unsigned flags);
|
||||||
|
|
||||||
~Ring() noexcept {
|
~Ring() noexcept {
|
||||||
|
@ -28,23 +33,50 @@ public:
|
||||||
Ring(const Ring &) = delete;
|
Ring(const Ring &) = delete;
|
||||||
Ring &operator=(const Ring &) = delete;
|
Ring &operator=(const Ring &) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the io_uring file descriptor.
|
||||||
|
*/
|
||||||
FileDescriptor GetFileDescriptor() const noexcept {
|
FileDescriptor GetFileDescriptor() const noexcept {
|
||||||
return FileDescriptor(ring.ring_fd);
|
return FileDescriptor(ring.ring_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a submit queue entry or nullptr if the submit queue
|
||||||
|
* is full.
|
||||||
|
*/
|
||||||
struct io_uring_sqe *GetSubmitEntry() noexcept {
|
struct io_uring_sqe *GetSubmitEntry() noexcept {
|
||||||
return io_uring_get_sqe(&ring);
|
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();
|
void Submit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for one completion.
|
||||||
|
*
|
||||||
|
* Throws on error.
|
||||||
|
*
|
||||||
|
* @return a completion queue entry or nullptr on EAGAIN
|
||||||
|
*/
|
||||||
struct io_uring_cqe *WaitCompletion();
|
struct io_uring_cqe *WaitCompletion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Peek one completion (non-blocking).
|
||||||
|
*
|
||||||
|
* Throws on error.
|
||||||
|
*
|
||||||
* @return a completion queue entry or nullptr on EAGAIN
|
* @return a completion queue entry or nullptr on EAGAIN
|
||||||
*/
|
*/
|
||||||
struct io_uring_cqe *PeekCompletion();
|
struct io_uring_cqe *PeekCompletion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark one completion event as consumed.
|
||||||
|
*/
|
||||||
void SeenCompletion(struct io_uring_cqe &cqe) noexcept {
|
void SeenCompletion(struct io_uring_cqe &cqe) noexcept {
|
||||||
io_uring_cqe_seen(&ring, &cqe);
|
io_uring_cqe_seen(&ring, &cqe);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue