io_uring_peek_cqe(3)

πŸ“¦
version 2.15 Β· 3 versions
, in alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– io_uring_peek_cqe β€” liburing manual, but make it cute ✨

okay bestie, pull up a chair πŸͺ‘ because we're talking about io_uring_peek_cqe(3) β€” yes it's a real function, yes it lives in the liburing manual, and yes it's about to be your new fave πŸ’…


✨ NAME ✨

io_uring_peek_cqe β€” literally just checking if an io_uring completion event is ready for you, no waiting, no drama 🌸


πŸŽ€ SYNOPSIS πŸŽ€

#include <liburing.h>

int io_uring_peek_cqe(struct io_uring *ring,
                      struct io_uring_cqe **cqe_ptr);

unsigned io_uring_peek_batch_cqe(struct io_uring *ring,
                                 struct io_uring_cqe **cqe_ptrs,
                                 unsigned count);

two functions, one vibe. one peeks a single CQE, the other peeks a whole little squad of them 🫢


πŸ’œ DESCRIPTION πŸ’œ

okay so first up, io_uring_peek_cqe(3). this function returns an IO completion from the queue that belongs to the ring param β€” but only if one is already sitting there, readily available πŸ‘€. on a successful return, the cqe_ptr param gets filled with a valid CQE entry, and you're good to go ✨.

here's the important part, bestie: this function does not enter the kernel to wait for an event. like, it will not go knock on the kernel's door and be like "hello?? any completions??" πŸ™ˆ. an event is only returned if it's already available in the CQ ring. it's giving "if you know, you know" β€” if it's there, you get it, if it's not, you don't πŸ’€.

then we have io_uring_peek_batch_cqe(3), the group-chat version πŸ“±. it returns up to count request completions in cqe_ptrs, belonging to the ring param, if they're readily available. same energy as above β€” it will not enter the kernel, unless the CQ ring is in an overflow condition 😳 (that's the one exception, don't forget it). upon successful return, cqe_ptrs are filled with the number of events indicated by the return value. iconic behaviour, no cap πŸ‘‘


🌈 RETURN VALUE 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

go read those too, they're all part of the same friend group πŸ’…βœ¨


and that's the whole page, bestie πŸŽ€ this one's from liburing-2.2, dated March 12, 2022 β€” so you know it's been serving reliable peek energy since then πŸ‘‘πŸ«Ά periodt.

πŸ“¦ where this page comes from