qbrb.h(3)

qbrb.h3

This implements a ring buffer that works in "chunks", not bytes.

Usage

#include <qb/qbrb.h>

Overview

So you write/read a complete chunk or not at all. There are two types of ring buffer: normal and overwrite. Overwrite will reclaim the oldest chunks inorder to make way for new ones, the normal version will refuse to write a new chunk if the ring buffer is full.

This implementation is capable of working across processes, but one process must only write and the other process read.

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);

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);

Releases

6 releases since Debian 9 (Stretch); the text changed 5 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13
  6. Arch

From libqb 2.0.10-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.