mpr/buf.cpp File Reference


Detailed Description

Fast, growable buffer mechanism using a ring queue metaphore.

Overview:
This buffer implementation provides a growable buffer mechanism that strives for maximal usage of space. It is also designed to be as fast as possible. It is the callers responsibility to do thread synchronization.

The internal interface is somewhat exposed to the caller via methods, but the design paradigm of ring buffers is very stable and not expected or even desired to change.

Operation of a buffer: buflen is the size of the buffer. buf points to the start of the buffer. start points to the next byte of data to be read. end points to the next available space to store new data endbuf points just past the end of the buffer.

The buffer is empty if start == end. The buffer will thus hold at most buflen -1 bytes. If a pointer is incremented past the end of the buffer, we always wrap before returning.
Remarks:
This module is not thread-safe. It is the callers responsibility to perform all thread synchronization.

© Mbedthis Software LLC, 2003-2004. All rights reserved. Mbedthis is a trademark of Mbedthis Software LLC.