io_uring_wait_cqe_nr(3)

πŸ“¦
version 2.15 Β· 2 versions
  • 2.15 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 2.5 Β· debian bookworm, ubuntu noble
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– io_uring_wait_cqe_nr β€” the liburing manual, bestie edition πŸ’–

okay so you're deep in liburing land and you need your completions to actually, like, arrive. this page is your girl. no cap.


✨ NAME ✨

io_uring_wait_cqe_nr β€” wait for one or more io_uring completion events πŸ¦‹


🌸 SYNOPSIS 🌸

#include <liburing.h>

int io_uring_wait_cqe_nr(struct io_uring *ring,
                         struct io_uring_cqe **cqe_ptr,
                         unsigned wait_nr);

πŸ’… DESCRIPTION πŸ’…

so io_uring_wait_cqe_nr(3) hands you back wait_nr IO completion events from the queue that belongs to the ring param, and it will wait for them if it has to. but here's the tea: if the number of events you're asking for is already sitting in the ring when you call it, it does not wait at all. zero patience, love that for it. the cqe_ptr param gets filled in on success. πŸ’–

once you've submitted a request with io_uring_submit(3), your application can go grab the completion with io_uring_wait_cqe(3).

now for the iconic part: ideally you're using this with a ring that was set up with IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_DEFER_TASKRUN, because that combo greatly reduces the number of context switches an application sees while it's waiting on a whole pile of requests. it's giving efficiency. it's giving main character energy. πŸ”₯


⭐ RETURN VALUE ⭐

on success, io_uring_wait_cqe_nr(3) returns 0 and the cqe_ptr param is filled in. on failure it returns -errno. πŸ™ˆ

okay important thing bestie: the return value is about the result of waiting for a CQE. it has no relation to the CQE result itself. don't mix those up, i'm begging. 😭

πŸŽ€ SEE ALSO πŸŽ€


this page is from liburing-2.1, dated November 15, 2021 β€” the io_uring_wait_cqe_nr(3) era, and honestly? iconic. mwah. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from