QBRB.H(3)

NAME
qbrb.h - This implements a ring buffer that works in "chunks", not bytes.

SYNOPSIS
#include <qb/qbrb.h>

DESCRIPTION

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

SEE ALSO

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.