|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
A statically-sized, non-atomic ring buffer state machine. More...
#include <ring_buffer.h>
Public Types | |
| using | Ix = IxTy |
Public Member Functions | |
| void | reset () |
| Reset cursors to an empty state. | |
| bool | is_empty () |
| Is this ring empty? | |
| bool | head_get (Ix &v) |
| Try to retrieve the head index; returns true if available and false otherwise. | |
| Ix | head_get_unsafe () |
| Retrieve the head index while bypassing the emptiness check. | |
| void | head_advance () |
| Discard the element at the index returned by head_get(). | |
| bool | tail_get (Ix &v) |
| Try to retrieve the index of the tail, if nonempty. | |
| bool | tail_next (Ix &v) |
| Try to retrieve the index beyond the tail, if there is room. | |
| void | tail_advance () |
| Make the next element available. | |
A statically-sized, non-atomic ring buffer state machine.
The actual element storage must be provided externally; all this does is manage the cursors. This representation uses an explicit empty flag, rather than considering equal cursors to be empty, so as to not need an extra element of store Capacity-many items.
The type of the cursors is parametric, but must be unsigned.
The consumer workflow is:
The producer workflow is:
Definition at line 39 of file ring_buffer.h.
| using ds::ring_buffer::Cursors< Debug, Capacity, IxTy >::Ix = IxTy |
Definition at line 48 of file ring_buffer.h.
|
inline |
Discard the element at the index returned by head_get().
Do not call this unless there was a matching call to head_get() that has returned true.
Definition at line 125 of file ring_buffer.h.
|
inline |
Try to retrieve the head index; returns true if available and false otherwise.
Definition at line 99 of file ring_buffer.h.
References is_empty().
|
inline |
Retrieve the head index while bypassing the emptiness check.
The caller must have reason to believe that the ring is not empty.
Definition at line 114 of file ring_buffer.h.
|
inline |
Is this ring empty?
Definition at line 90 of file ring_buffer.h.
Referenced by head_get(), and tail_get().
|
inline |
Reset cursors to an empty state.
Definition at line 80 of file ring_buffer.h.
|
inline |
Make the next element available.
Do not call this unless there was a matching call to tail_next() that returned true.
Definition at line 173 of file ring_buffer.h.
|
inline |
Try to retrieve the index of the tail, if nonempty.
Definition at line 138 of file ring_buffer.h.
References is_empty().
|
inline |
Try to retrieve the index beyond the tail, if there is room.
Returns true and sets the index if so, or returns false if not.
Definition at line 155 of file ring_buffer.h.