ring_head Struct Reference

Ring buffer management data. More...

#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.


Detailed Description

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 65 of file ring.h.


Field Documentation

unsigned long ring_head::head

unsigned long ring_head::tail


The documentation for this struct was generated from the following file:

Generated on Tue Sep 15 10:22:24 2009 for libavr32 by  doxygen 1.5.8