1io_uring_for_each_cqe(3)        liburing Manual       io_uring_for_each_cqe(3)
2
3
4

NAME

6       io_uring_for_each_cqe - iterate pending completion events
7

SYNOPSIS

9       #include <liburing.h>
10
11       io_uring_for_each_cqe(struct io_uring *ring,
12                             unsigned head,
13                             struct io_uring_cqe *cqe) { }
14

DESCRIPTION

16       The io_uring_for_each_cqe(3) is a macro helper that iterates completion
17       events belonging to the ring using head as a  temporary  iterator,  and
18       points cqe to each pending event when iterating.
19
20       This  helper provides an efficient way to iterate all pending events in
21       the ring, and then advancing the CQ  ring  by  calling  io_uring_cq_ad‐
22       vance(3)  with  the  number of CQEs consumed when done. As updating the
23       kernel visible CQ ring state involves an ordered write, doing  it  once
24       for  a number of events is more efficient than handling each completion
25       separately and calling io_uring_cqe_seen(3) for each of them.
26
27

EXAMPLE

29       void handle_cqes(struct io_uring *ring)
30       {
31            struct io_uring_cqe *cqe;
32            unsigned head;
33            unsigned i = 0;
34
35            io_uring_for_each_cqe(ring, head, cqe) {
36                 /* handle completion */
37                 printf("cqe: %d\n", cqe->res);
38                 i++;
39            }
40
41            io_uring_cq_advance(ring, i);
42       }
43
44

RETURN VALUE

46       None
47

SEE ALSO

49       io_uring_wait_cqe_timeout(3),       io_uring_wait_cqe(3),        io_ur‐
50       ing_wait_cqes(3), io_uring_cqe_seen(3), io_uring_buf_ring_cq_advance(3)
51
52
53
54liburing-2.4                     June 04, 2023        io_uring_for_each_cqe(3)
Impressum