#include <ring.h>
Data Fields | |
| unsigned long | head |
| Offset of the next free entry in the buffer. | |
| unsigned long | tail |
| Offset of the first used entry in the buffer. | |
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 65 of file ring.h.
| unsigned long ring_head::head |
Offset of the next free entry in the buffer.
Definition at line 67 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 long ring_head::tail |
Offset of the first used entry in the buffer.
Definition at line 69 of file ring.h.
Referenced by console_buf_extract_char(), 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.5.8