SD_BUS_GET_N_QUEUED_READ(3)
π SD_BUS_GET_N_QUEUED_READ(3) π
okay bestie, welcome to the sd_bus_get_fd manual page β yes that's the page family, we're just hanging out in the queue-counting corner of it today π buckle up, this one's actually pretty chill.
β¨ NAME β¨
sd_bus_get_n_queued_read, sd_bus_get_n_queued_write β get the number of pending bus messages chillin' in the read and write queues of a bus connection object π
πΈ SYNOPSIS πΈ
#include <systemd/sd-bus.h>
int sd_bus_get_n_queued_read(sd_bus *bus, uint64_t *ret);
int sd_bus_get_n_queued_write(sd_bus *bus, uint64_t *ret);
π¦ DESCRIPTION π¦
So sd_bus_get_n_queued_read() is literally your girl for asking "how many bus messages are sitting in the read queue of this bus connection object rn?" π The read queue holds all the messages that have been read from the transport medium (think: a network socket, iykyk) but that haven't been processed locally yet. It's giving "inbox energy."
The function takes two arguments: the bus object you wanna query, and a pointer to a uint64_t 64-bit counter variable where the current queue size gets written. That's it, that's the whole vibe π«Ά
Wanna actually shrink that read queue? Use sd_bus_process() β that's the one that processes queued messages, which reduces the read queue size (and honestly, the write queue too, see below, it's a whole thing π).
Similarly, sd_bus_get_n_queued_write() is the matching icon for querying the number of currently pending bus messages in the write queue of a bus connection object β¨ The write queue holds all the messages that got enqueued into the connection via a call like sd_bus_send() but that haven't been written out to the transport medium yet. The arguments are the same as sd_bus_get_n_queued_read() β same shape, same energy π
Here too, use sd_bus_process() if you wanna reduce the size of the write queue. Or, alternate route: use sd_bus_flush() to synchronously write out any pending bus messages until the write queue is literally empty. no cap, empty empty π§
β RETURN VALUE β
On success, these functions return 0 or a positive integer π On failure, they return a negative errno-style error code (rude, but okay).
π Errors
Returned errors may indicate the following problems:
-ECHILDβ the bus connection was created in a different process, library or module instance. bestie... that's not your bus. π«
π NOTES π
The functions described here are available as a shared library, which you can compile against and link to with the libsystemd pkg-config(1) file π
All functions listed here are thread-agnostic, and only a single thread may operate on a given object at any given time β° Different threads may access the same object at different times β no double-teaming. Multiple independent objects, though? Go off, use them from different threads in parallel, that's totally fine π β¨
β οΈ okay important one: the code described here usesgetenv(3), which is declared to be not multi-thread-safe. That means the code calling the functions described here must not callsetenv(3)from a parallel thread. It's recommended to only make calls tosetenv()from an early phase of the program, back when no other threads have been started π
π₯ HISTORY π₯
sd_bus_get_n_queued_read() and sd_bus_get_n_queued_write() were added in version 238 β vintage, but iconic π
π SEE ALSO π
systemd(1), sd-bus(3), sd_bus_process(3), sd_bus_send(3), sd_bus_flush(3)
that's the whole page, bestie β go count some queues π this was systemd 261.3, page SD_BUS_GET_N_QUEUED_READ(3), brought to you by the sd_bus_get_fd manual family. mwah πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libsystemd-dev 261.3-0ubuntu3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms