QBRB.H(3)
π QBRB.H β the ring buffer page, but make it make sense π
okay bestie, this is qbrb.h, straight out of the libqb Programmer's Manual. it's a header, it's a whole vibe, and it's about to become your new hyperfixation. grab a snack. π
β¨ NAME β¨
qbrb.h β this implements a ring buffer that works in "chunks", not bytes. periodt. π
π SYNOPSIS π
#include <qb/qbrb.h>
that's it. that's the whole synopsis. iconic. π
π¦ DESCRIPTION π¦
so here's the tea: you write a complete chunk or you write nothing at all. no half-chunks, no lil byte-by-byte nibbling. it's giving all-or-nothing and honestly? respect. π
there are two types of ring buffer:
- normal β this one will refuse to write a new chunk if the ring buffer is full. it's full, it said what it said, no more room bestie. π
- overwrite β this one will reclaim the oldest chunks inorder to make way for the new ones. out with the old, in with the new, main character energy only. β¨
this implementation is capable of working across processes, BUT β and this is the important part β one process must only write and the other process read. one writer, one reader. that's the arrangement. do not test it. π
πΈ the read process will do the following:
rb = qb_rb_open("test2", 2000, QB_RB_FLAG_SHARED_PROCESS|QB_RB_FLAG_CREATE);
for (i = 0; i < 200; i++) {
try_read_again:
l = qb_rb_chunk_read(rb, (void *)out, 32, 1000);
if (l < 0) {
goto try_read_again;
}
}
...
qb_rb_close(rb);
look at that goto hopping back like it's got somewhere to be. it does. it's retrying. we love a persistent queen. π«Ά
π the write process will do the following:
rb = qb_rb_open("test2", 2000, QB_RB_FLAG_SHARED_PROCESS);
for (i = 0; i < 200; i++) {
try_write_again:
l = qb_rb_chunk_write(rb, &v, sizeof(v));
if (l < sizeof(v)) {
goto try_write_again;
}
}
...
qb_rb_close(rb);
note how the writer did not pass QB_RB_FLAG_CREATE β because the reader already made it. teamwork, fr fr. π§
β οΈ reminder bestie: one process writes, the other reads. that's the whole deal. don't get cute with it.
π SEE ALSO π
the whole friend group, go say hi:
qb_rb_close(3)qb_rb_refcount_get(3)qb_rb_chmod(3)qb_rb_chown(3)qb_rb_open(3)qb_rb_write_to_file(3)qb_rb_create_from_file(3)qb_rb_chunks_used(3)qb_rb_chunk_reclaim(3)qb_rb_space_used(3)qb_rb_chunk_write(3)qb_rb_shared_user_data_get(3)qb_rb_chunk_commit(3)qb_rb_chunk_peek(3)qb_rb_space_free(3)qb_rb_name_get(3)qb_rb_chunk_alloc(3)qb_rb_chunk_read(3)
π COPYRIGHT π
Copyright (C) 2010-2020 Red Hat, Inc.
and that's the page bestie!! π it came from the LIBQB crew, dated 2025-09-16, and it lives at the address QBRB.H(3) β iykyk. go forth and buffer responsibly. mwah. πππ
π¦ where this page comes from
- fedora 44: libqb-devel 2.0.9-2.fc44 Β· LGPL-2.1-or-later
- fedora 44: libqb-devel 2.0.9-2.fc44 Β· LGPL-2.1-or-later
- ubuntu resolute: libqb-dev 2.0.9-1ubuntu1 Β· LGPL-2.1-or-later
- ubuntu stonking: libqb-dev 2.0.9-1ubuntu1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms