Ring buffer management data. More...
#include <ring.h>
Data Fields | |
| unsigned int | head |
| Offset of the next free entry in the buffer. | |
| unsigned int | tail |
| Offset of the first used entry in the buffer. | |
Ring buffer management data.
This keeps track of the state of the ring buffer. The actual buffer is user-defined. Typically, this struct is embedded into the same struct as the ring buffer itself, but this is not a requirement.
Note that head and tail are incremented without wrapping as items are added to the buffer, so they can't be used directly as offsets (they may point far outside the buffer). Always use ring_get_head() and ring_get_tail(), which always return offsets within the buffer, to access them.
Also note that in order to keep the size and complexity of the code down, this structure does not keep track of the size of the ring buffer. The caller must pass the size as a parameter to the functions which need it. This improves the code size and speed significantly when the buffer size is constant.
Definition at line 103 of file ring.h.
| unsigned int ring_head::head |
Offset of the next free entry in the buffer.
Definition at line 105 of file ring.h.
Referenced by ring_entries_unused_before_end(), ring_entries_used(), ring_entries_used_before_end(), ring_get_head(), ring_insert_entries(), ring_is_empty(), and ring_reset().
| unsigned int ring_head::tail |
Offset of the first used entry in the buffer.
Definition at line 107 of file ring.h.
Referenced by ring_entries_unused_before_end(), ring_entries_used(), ring_entries_used_before_end(), ring_extract_entries(), ring_get_tail(), ring_is_empty(), and ring_reset().
1.6.3