randolf.ca  1.00
Randolf Richardson's C++ classes
Loading...
Searching...
No Matches
randolf::rring_blocks Struct Reference

Structure of positions and lengths of data blocks in ring buffer memory. This is specifically useful for direct memory access to the ring buffer's memory, which will need to be split into two operations when the buffer straddles the memory boundary. More...

#include <rring_blocks>

+ Collaboration diagram for randolf::rring_blocks:

Public Attributes

void * avail1
 Pointer to first portion of available buffer memory.
 
size_t avail1_size
 Number of elements in avail1.
 
void * avail2
 Pointer to second portion of available buffer memory, if this part of the ring buffer straddles the boundary, otherwise nullptr will be specified.
 
size_t avail2_size
 Number of elements in avail2.
 
void * block1
 Pointer to first portion of utilized buffer memory.
 
size_t block1_size
 Number of elements in block1.
 
void * block2
 Pointer to second portion of utilized buffer memory, if this part of the ring buffer straddles the boundary, otherwise nullptr will be specified.
 
size_t block2_size
 Number of elements in block2.
 

Detailed Description

Structure of positions and lengths of data blocks in ring buffer memory. This is specifically useful for direct memory access to the ring buffer's memory, which will need to be split into two operations when the buffer straddles the memory boundary.

Note
The following code demonstrates how to access ring buffer memory:
#include <randolf/rring>
#include <randolf/rring_blocks>
// ... code that initializes a ring buffer and populates it; documentation
// for this is available in the @ref rring class ...
char b1 = 0;
char b2 = 0;
char a1 = 0;
char a2 = 0;
std::shared_ptr<randolf::rring_blocks> rblk = rb.get_data_blocks();
if (rblk->block1 != nullptr) // Check for pointer (avoids segfault)
b1 = ((char*)rblk->block1)[0]; // First byte of utilized buffer memory
if (rblk->block2 != nullptr) // Check for pointer (avoids segfault)
b2 = ((char*)rblk->block2)[0]; // Second byte of utilized buffer memory
if (rblk->avail1 != nullptr) // Check for pointer (avoids segfault)
a1 = ((char*)rblk->avail1)[0]; // First byte of available buffer memory
if (rblk->avail2 != nullptr) // Check for pointer (avoids segfault)
a2 = ((char*)rblk->avail1)[0]; // Second byte of available buffer memory
See also
rring::get_data_blocks
History
  • 2024-Dec-03 v1.00 Initial version
Version
1.00
Author
Randolf Richardson

Member Data Documentation

◆ block1

void* randolf::rring_blocks::block1

Pointer to first portion of utilized buffer memory.

◆ block2

void* randolf::rring_blocks::block2

Pointer to second portion of utilized buffer memory, if this part of the ring buffer straddles the boundary, otherwise nullptr will be specified.

◆ avail1

void* randolf::rring_blocks::avail1

Pointer to first portion of available buffer memory.

◆ avail2

void* randolf::rring_blocks::avail2

Pointer to second portion of available buffer memory, if this part of the ring buffer straddles the boundary, otherwise nullptr will be specified.

◆ block1_size

size_t randolf::rring_blocks::block1_size

Number of elements in block1.

◆ block2_size

size_t randolf::rring_blocks::block2_size

Number of elements in block2.

◆ avail1_size

size_t randolf::rring_blocks::avail1_size

Number of elements in avail1.

◆ avail2_size

size_t randolf::rring_blocks::avail2_size

Number of elements in avail2.


The documentation for this struct was generated from the following file: