5 /*======================================================================*//**
7 Structure of positions and lengths of data blocks in ring buffer memory.
8 This is specifically useful for direct memory access to the ring buffer's
9 memory, which will need to be split into two operations when the buffer
10 straddles the memory boundary.
13 The following code demonstrates how to access ring buffer memory:
15 #include <randolf/rring>
16 #include <randolf/rring_blocks>
18 // ... code that initializes a ring buffer and populates it; documentation
19 // for this is available in the @ref rring class ...
26 std::shared_ptr<randolf::rring_blocks> rblk = rb.get_data_blocks();
28 if (rblk->block1 != nullptr) // Check for pointer (avoids segfault)
29 b1 = ((char*)rblk->block1)[0]; // First byte of utilized buffer memory
31 if (rblk->block2 != nullptr) // Check for pointer (avoids segfault)
32 b2 = ((char*)rblk->block2)[0]; // Second byte of utilized buffer memory
34 if (rblk->avail1 != nullptr) // Check for pointer (avoids segfault)
35 a1 = ((char*)rblk->avail1)[0]; // First byte of available buffer memory
37 if (rblk->avail2 != nullptr) // Check for pointer (avoids segfault)
38 a2 = ((char*)rblk->avail1)[0]; // Second byte of available buffer memory
40 @see rring::get_data_blocks
42 - 2024-Dec-03 v1.00 Initial version
44 @author Randolf Richardson
45 *///=========================================================================
48 /*======================================================================*//**
50 Pointer to first portion of utilized buffer memory.
51 *///=========================================================================
54 /*======================================================================*//**
56 Pointer to second portion of utilized buffer memory, if this part of the ring
57 buffer straddles the boundary, otherwise @c nullptr will be specified.
58 *///=========================================================================
61 /*======================================================================*//**
63 Pointer to first portion of available buffer memory.
64 *///=========================================================================
67 /*======================================================================*//**
69 Pointer to second portion of available buffer memory, if this part of the
70 ring buffer straddles the boundary, otherwise @c nullptr will be specified.
71 *///=========================================================================
74 /*======================================================================*//**
76 Number of elements in @ref block1.
77 *///=========================================================================
80 /*======================================================================*//**
82 Number of elements in @ref block2.
83 *///=========================================================================
86 /*======================================================================*//**
88 Number of elements in @ref avail1.
89 *///=========================================================================
92 /*======================================================================*//**
94 Number of elements in @ref avail2.
95 *///=========================================================================
98 }; // -x- struct rring_blocks -x-
100}; // -x- namespace randolf -x-