5 /*======================================================================*//**
7 This structure contains a Block Allocation Map (BAM) of the positions and
8 lengths of data blocks in ring buffer memory. This is part of an advanced
9 feature that's specifically useful for direct memory access to the ring
10 buffer's memory (access operations will likely need to be split into two
11 operations when the buffer straddles the ring buffer's memory boundary, which
12 benefits performance by making direct read/write operations with file and
13 socket I/O, but for most applications it's better to use the other methods
14 provided in the @ref randolf::rring class since this is what they were
18 This code demonstrates how to obtain a "bam" and access ring buffer memory by
22 #include <randolf/rring>
23 #include <randolf/rring_bam>
25 // ... code that initializes a ring buffer and populates it; documentation
26 // for the data_bam() method is available in the randolf::rring class ...
33 randolf::rring_bam bam = rb.data_bam();
35 if (bam->block1 != nullptr) // Check for pointer (avoids segfault)
36 b1 = ((char*)bam->block1)[0]; // First byte of utilized buffer memory
38 if (bam->block2 != nullptr) // Check for pointer (avoids segfault)
39 b2 = ((char*)bam->block2)[0]; // Second byte of utilized buffer memory
41 if (bam->avail1 != nullptr) // Check for pointer (avoids segfault)
42 a1 = ((char*)bam->avail1)[0]; // First byte of available buffer memory
44 if (bam->avail2 != nullptr) // Check for pointer (avoids segfault)
45 a2 = ((char*)bam->avail1)[0]; // Second byte of available buffer memory
47 @see randolf::rring::data_bam
49 - 2024-Dec-03 v1.00 Initial version
51 @author Randolf Richardson
52 *///=========================================================================
55 /*======================================================================*//**
57 Pointer to first portion of utilized buffer memory.
58 *///=========================================================================
61 /*======================================================================*//**
63 Pointer to second portion of utilized buffer memory, if this part of the ring
64 buffer straddles the boundary, otherwise @c nullptr will be specified.
65 *///=========================================================================
68 /*======================================================================*//**
70 Pointer to first portion of available buffer memory.
71 *///=========================================================================
74 /*======================================================================*//**
76 Pointer to second portion of available buffer memory, if this part of the
77 ring buffer straddles the boundary, otherwise @c nullptr will be specified.
78 *///=========================================================================
81 /*======================================================================*//**
83 Number of elements in @ref block1.
84 *///=========================================================================
87 /*======================================================================*//**
89 Number of elements in @ref block2.
90 *///=========================================================================
93 /*======================================================================*//**
95 Number of elements in @ref avail1.
96 *///=========================================================================
99 /*======================================================================*//**
101 Number of elements in @ref avail2.
102 *///=========================================================================
105 }; // -x- struct rring_bam -x-
107}; // -x- namespace randolf -x-