1QBRB.H(3) libqb Programmer's Manual QBRB.H(3)
2
3
4
6 qbrb.h - This implements a ring buffer that works in "chunks", not
7 bytes.
8
9
11 #include <qb/qbrb.h>
12
14 So you write/read a complete chunk or not at all. There are two types
15 of ring buffer: normal and overwrite. Overwrite will reclaim the oldest
16 chunks inorder to make way for new ones, the normal version will refuse
17 to write a new chunk if the ring buffer is full.
18
19 This implementation is capable of working across processes, but one
20 process must only write and the other process read.
21
22 The read process will do the following:
23
24 rb = qb_rb_open("test2", 2000, QB_RB_FLAG_SHARED_PROCESS|QB_RB_FLAG_CREATE);
25 for (i = 0; i < 200; i++) {
26 try_read_again:
27 l = qb_rb_chunk_read(rb, (void *)out, 32, 1000);
28 if (l < 0) {
29 goto try_read_again;
30 }
31 }
32 ...
33 qb_rb_close(rb);
34
35
36 The write process will do the following:
37
38 rb = qb_rb_open("test2", 2000, QB_RB_FLAG_SHARED_PROCESS);
39 for (i = 0; i < 200; i++) {
40 try_write_again:
41 l = qb_rb_chunk_write(rb, &v, sizeof(v));
42 if (l < sizeof(v)) {
43 goto try_write_again;
44 }
45 }
46 ...
47 qb_rb_close(rb);
48
49
51 qb_rb_close(3), qb_rb_refcount_get(3), qb_rb_chmod(3), qb_rb_chown(3),
52 qb_rb_open(3), qb_rb_write_to_file(3), qb_rb_create_from_file(3),
53 qb_rb_chunks_used(3), qb_rb_chunk_reclaim(3), qb_rb_space_used(3),
54 qb_rb_chunk_write(3), qb_rb_shared_user_data_get(3),
55 qb_rb_chunk_commit(3), qb_rb_chunk_peek(3), qb_rb_space_free(3),
56 qb_rb_name_get(3), qb_rb_chunk_alloc(3), qb_rb_chunk_read(3)
57
59 Copyright (C) 2010-2020 Red Hat, Inc.
60
61
62
63LIBQB 2023-07-21 QBRB.H(3)