diff options
author | Ammar Faizi <ammarfaizi2@gnuweeb.org> | 2023-06-09 08:54:03 +0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-06-08 21:00:08 -0600 |
commit | 298c083d75ecde5a8833366167b3b6abff0c8d39 (patch) | |
tree | 32cf2fe3c2b84ab756ed05142148237cea93e787 | |
parent | c8d06ed9bcbf2ae294242f9caacecfa01bf138b2 (diff) |
man/io_uring_for_each_cqe: Explicitly tell it's a macro and add an exampleliburing-2.4
Let the reader directly know that it's not a function, but a macro.
Also, give a simple example of its usage.
Co-authored-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20230609015403.3523811-3-ammarfaizi2@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | man/io_uring_for_each_cqe.3 | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/man/io_uring_for_each_cqe.3 b/man/io_uring_for_each_cqe.3 index 8445fd6..78d8f6f 100644 --- a/man/io_uring_for_each_cqe.3 +++ b/man/io_uring_for_each_cqe.3 @@ -17,7 +17,7 @@ io_uring_for_each_cqe \- iterate pending completion events .PP The .BR io_uring_for_each_cqe (3) -helper iterates completion events belonging to the +is a macro helper that iterates completion events belonging to the .I ring using .I head @@ -35,6 +35,24 @@ calling .BR io_uring_cqe_seen (3) for each of them. +.SH EXAMPLE +.EX +void handle_cqes(struct io_uring *ring) +{ + struct io_uring_cqe *cqe; + unsigned head; + unsigned i = 0; + + io_uring_for_each_cqe(ring, head, cqe) { + /* handle completion */ + printf("cqe: %d\\n", cqe->res); + i++; + } + + io_uring_cq_advance(ring, i); +} +.EE + .SH RETURN VALUE None .SH SEE ALSO |