vrb(3)

๐Ÿ“ฆ version 0.5.1, in nixos 26.05

๐ŸŽ€ vrb(3) โ€” from the VRB Programmer's Manual ๐ŸŽ€

okay bestie, this is the whole virtual ring buffer moment. ๐Ÿ’…

๐ŸŒธ NAME ๐ŸŒธ

vrb โ€” virtual ring buffer. that's the name, no cap. โœจ

๐Ÿ“š LIBRARY ๐Ÿ“š

  • -lvrb โ€” the library you link, bestie. ๐Ÿซถ

๐Ÿ“Ž HEADERS ๐Ÿ“Ž

#include <vrb.h>

โœจ DESCRIPTION โœจ

A virtual ring buffer is a character FIFO queue with a special property: any sequence of characters โ€” either the data present in the buffer, or any empty space โ€” may be accessed as a single contiguous block of memory. That eliminates the need to deal with breaks in string continuity just to test for wraparounds or splits, and it allows direct use of string construction or parsing tools, such as snprintf(3) or sscanf(3). ๐Ÿ”ฅ

As a character FIFO queue, data comes out in the same order as it was put in. Other FIFO queues and ring buffers have to chop up the data into pieces, and/or copy the data between caller space and buffer space. The virtual ring buffer does not have to do that: it lets the calling program access the buffer space directly, because the data to be accessed to get from the buffer, or the space to be accessed to put data into the buffer, is always addressable as a single linear contiguous range of addresses. When the caller is going to have data to place into the buffer, it obtains the pointer and length of available space, and can place the data directly into the buffer, usually eliminating one step of copying. For example, the caller can use the pointer to read data directly into the buffer. Or it can call functions, such as snprintf(3), to make conversions directly. Likewise, when the caller is going to extract data from the buffer, it obtains the pointer and length of the data, and can directly address it in place. ๐ŸŒˆ

Once data has been placed into empty space, or extracted from a data space, the caller indicates how much was put in or taken out, and pointers are then updated accordingly. ๐Ÿซถ

The VRB functions never copy data around within the buffer. The property of always having a linear range of memory for both all the data in the buffer as well as all the empty space in the buffer is implemented by memory mapping two virtual memory ranges to the same memory object, and making those two ranges immediately adjacent. Thus anything in the first range is seen identically in the second range. A span of data or empty space that would wrap around is now simply extended from the first range into the second range. ๐Ÿ’ซ

๐Ÿ› ๏ธ FUNCTIONS ๐Ÿ› ๏ธ

  • vrb_new โ€” create a new virtual ring buffer. ๐ŸŒฑ
  • vrb_new_opt โ€” create a new virtual ring buffer with options. โš™๏ธ
  • vrb_destroy โ€” destroy an allocated virtual ring buffer. ๐Ÿ’ฅ
  • vrb_init โ€” initialize a virtual ring buffer in a static struct. ๐Ÿงฑ
  • vrb_init_opt โ€” initialize a virtual ring buffer in a static struct with options. ๐Ÿงฐ
  • vrb_uninit โ€” uninitialize a virtual ring buffer in a static struct. ๐Ÿงน
  • vrb_capacity โ€” obtain the total buffer capacity of a VRB. ๐Ÿ“
  • vrb_data_len โ€” obtain the length of data in the buffer. ๐Ÿ“Š
  • vrb_data_ptr โ€” obtain the pointer to the data in the buffer. ๐Ÿ‘‰
  • vrb_space_len โ€” obtain the length of empty space in the buffer. ๐Ÿซง
  • vrb_space_ptr โ€” obtain the pointer to the empty space in the buffer. ๐Ÿช„
  • vrb_is_empty โ€” determine if the buffer is currently empty. ๐Ÿ•ณ๏ธ
  • vrb_is_full โ€” determine if the buffer is currently full. ๐Ÿˆต
  • vrb_is_not_empty โ€” determine if there is at least some data in the buffer. โœ…
  • vrb_is_not_full โ€” determine if there is at least some empty space in the buffer. ๐Ÿซถ
  • vrb_give โ€” indicate how much empty space had data put in by the caller. ๐ŸŽ
  • vrb_take โ€” indicate how much data in the buffer was used by the caller. ๐Ÿฝ๏ธ
  • vrb_get โ€” copy data from the virtual ring buffer to a caller location. ๐Ÿ“ค
  • vrb_get_min โ€” copy a minimum amount of data from the VRB only if it will fit. ๐Ÿงฎ
  • vrb_put โ€” copy data from a caller location to the virtual ring buffer. ๐Ÿ“ฅ
  • vrb_put_all โ€” copy data to the VRB only if all of it will fit. ๐ŸŽฏ
  • vrb_read โ€” read(2) data into a VRB until EOF or full, or I/O would block. ๐Ÿ“–
  • vrb_read_min โ€” read(2) a minimum amount of data into a VRB until EOF or full, or I/O would block. ๐Ÿ“š
  • vrb_write โ€” write(2) data from a VRB until empty, or I/O would block. โœ๏ธ
  • vrb_resize โ€” change the size of a VRB while keeping any data in the buffer. ๐Ÿ“
  • vrb_move โ€” move data from one VRB to another. ๐Ÿšš

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

go check out vrb_capacity(3), vrb_data_len(3), vrb_data_ptr(3), vrb_destroy(3), vrb_get(3), vrb_get_min(3), vrb_give(3), vrb_init(3), vrb_init_opt(3), vrb_is_empty(3), vrb_is_full(3), vrb_is_not_empty(3), vrb_is_not_full(3), vrb_move(3), vrb_new(3), vrb_new_opt(3), vrb_put(3), vrb_put_all(3), vrb_read(3), vrb_read_min(3), vrb_resize(3), vrb_space_len(3), vrb_space_ptr(3), vrb_take(3), vrb_uninit(3), vrb_write(3), vrb_write_min(3). ๐Ÿฆ‹

that's the whole vibe, bestie โ€” source/version: vrb, date: 2002-09-30. mwah ๐Ÿ’‹๐Ÿซถ

๐Ÿ“ฆ where this page comes from