This file contains the definition of a GWEN_RINGBUFFER. More...
Typedefs | |
typedef struct GWEN_RINGBUFFER | GWEN_RINGBUFFER |
Constructor And Destructor | |
| |
GWENHYWFAR_API GWEN_RINGBUFFER * | GWEN_RingBuffer_new (unsigned int size) |
GWENHYWFAR_API void | GWEN_RingBuffer_free (GWEN_RINGBUFFER *rb) |
Reading And Writing | |
| |
GWENHYWFAR_API int | GWEN_RingBuffer_WriteBytes (GWEN_RINGBUFFER *rb, const char *buffer, uint32_t *size) |
GWENHYWFAR_API int | GWEN_RingBuffer_WriteByte (GWEN_RINGBUFFER *rb, char c) |
GWENHYWFAR_API int | GWEN_RingBuffer_ReadBytes (GWEN_RINGBUFFER *rb, char *buffer, uint32_t *size) |
GWENHYWFAR_API int | GWEN_RingBuffer_ReadByte (GWEN_RINGBUFFER *rb) |
Informational Functions | |
| |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetUsedBytes (const GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetBytesLeft (const GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetBufferSize (const GWEN_RINGBUFFER *rb) |
Statistical Functions | |
| |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetEmptyCounter (const GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API void | GWEN_RingBuffer_ResetEmptyCounter (GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetFullCounter (const GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API void | GWEN_RingBuffer_ResetFullCounter (GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetThroughput (GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API void | GWEN_RingBuffer_ResetThroughput (GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetMaxUsedBytes (const GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API void | GWEN_RingBuffer_ResetMaxUsedBytes (GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API void | GWEN_RingBuffer_Reset (GWEN_RINGBUFFER *rb) |
Functions For Direct Manipulation Of The Buffer | |
Please use these functions with care. These function are supported in order to avoid unnecessary copying. | |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetMaxUnsegmentedRead (GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API uint32_t | GWEN_RingBuffer_GetMaxUnsegmentedWrite (GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API void | GWEN_RingBuffer_SkipBytesRead (GWEN_RINGBUFFER *rb, uint32_t psize) |
GWENHYWFAR_API void | GWEN_RingBuffer_SkipBytesWrite (GWEN_RINGBUFFER *rb, uint32_t psize) |
GWENHYWFAR_API const char * | GWEN_RingBuffer_GetReadPointer (const GWEN_RINGBUFFER *rb) |
GWENHYWFAR_API char * | GWEN_RingBuffer_GetWritePointer (const GWEN_RINGBUFFER *rb) |
This file contains the definition of a GWEN_RINGBUFFER.
typedef struct GWEN_RINGBUFFER GWEN_RINGBUFFER |
Definition at line 48 of file ringbuffer.h.
GWENHYWFAR_API void GWEN_RingBuffer_free | ( | GWEN_RINGBUFFER * | rb | ) |
Destructor.
Definition at line 55 of file ringbuffer.c.
References DBG_MEM_DEC, and GWEN_FREE_OBJECT.
Referenced by GWEN_SyncIo_Buffered_FreeData().
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetBufferSize | ( | const GWEN_RINGBUFFER * | rb | ) |
Returns the size of the ring buffer.
Definition at line 234 of file ringbuffer.c.
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetBytesLeft | ( | const GWEN_RINGBUFFER * | rb | ) |
Returns the number of bytes which still can be stored inside the ring buffer.
Definition at line 227 of file ringbuffer.c.
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetEmptyCounter | ( | const GWEN_RINGBUFFER * | rb | ) |
Returns the number of times the buffer was empty.
Definition at line 325 of file ringbuffer.c.
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetFullCounter | ( | const GWEN_RINGBUFFER * | rb | ) |
Returns the number of times the buffer was full.
Definition at line 311 of file ringbuffer.c.
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetMaxUnsegmentedRead | ( | GWEN_RINGBUFFER * | rb | ) |
Returns the maximum number of bytes which can be read with a following call to GWEN_RingBuffer_ReadBytes. This value (if not 0) can be used for GWEN_RingBuffer_SkipBytesRead.
Definition at line 105 of file ringbuffer.c.
References DBG_DEBUG, and GWEN_LOGDOMAIN.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetMaxUnsegmentedWrite | ( | GWEN_RINGBUFFER * | rb | ) |
Returns the maximum number of bytes which can be written with a following call to GWEN_RingBuffer_WriteBytes. This value (if not 0) can be used for GWEN_RingBuffer_SkipBytesWrite.
Definition at line 126 of file ringbuffer.c.
References DBG_DEBUG, and GWEN_LOGDOMAIN.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetMaxUsedBytes | ( | const GWEN_RINGBUFFER * | rb | ) |
Returns the maximum number of bytes which has been stored in the buffer.
Definition at line 283 of file ringbuffer.c.
GWENHYWFAR_API const char* GWEN_RingBuffer_GetReadPointer | ( | const GWEN_RINGBUFFER * | rb | ) |
Returne the current read pointer. Please note that the return value of GWEN_RingBuffer_GetMaxUnsegmentedRead indicates the maximum number of bytes at this position available! Trying to access bytes beyond that boundary will most likely result in segmentation faults. Please make sure that you call GWEN_RingBuffer_SkipBytesRead after taking data from the buffer in order to keep the internal structure intact.
Definition at line 339 of file ringbuffer.c.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetThroughput | ( | GWEN_RINGBUFFER * | rb | ) |
Returns the number of bytes which have passed through this buffer (i.e. bytes that have been written to and read from the buffer.
Definition at line 297 of file ringbuffer.c.
GWENHYWFAR_API uint32_t GWEN_RingBuffer_GetUsedBytes | ( | const GWEN_RINGBUFFER * | rb | ) |
Returns the number of bytes stored inside the ring buffer.
Definition at line 220 of file ringbuffer.c.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API char* GWEN_RingBuffer_GetWritePointer | ( | const GWEN_RINGBUFFER * | rb | ) |
Returne the current write pointer. Please note that the return value of GWEN_RingBuffer_GetMaxUnsegmentedWrite indicates the maximum number of bytes at this position available! Trying to access bytes beyond that boundary will most likely result in segmentation faults. Please make sure that you call GWEN_RingBuffer_SkipBytesWrite after writing data to the buffer in order to keep the internal structure intact.
Definition at line 346 of file ringbuffer.c.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API GWEN_RINGBUFFER* GWEN_RingBuffer_new | ( | unsigned int | size | ) |
Creates a new ring buffer
size | maximum size of the ring buffer |
Definition at line 42 of file ringbuffer.c.
References DBG_MEM_INC, and GWEN_NEW_OBJECT.
Referenced by GWEN_SyncIo_Buffered_new().
GWENHYWFAR_API int GWEN_RingBuffer_ReadByte | ( | GWEN_RINGBUFFER * | rb | ) |
Reads a single byte from the ring buffer.
Definition at line 262 of file ringbuffer.c.
References DBG_DEBUG, and GWEN_LOGDOMAIN.
GWENHYWFAR_API int GWEN_RingBuffer_ReadBytes | ( | GWEN_RINGBUFFER * | rb, | |
char * | buffer, | |||
uint32_t * | size | |||
) |
Read bytes from the ring buffer.
rb | ring buffer | |
buffer | pointer to the destination buffer | |
size | pointer to a variable that contains the number of bytes to read. Upon return this variable contains the number of bytes actually copied. |
Definition at line 182 of file ringbuffer.c.
References DBG_DEBUG, and GWEN_LOGDOMAIN.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API void GWEN_RingBuffer_Reset | ( | GWEN_RINGBUFFER * | rb | ) |
Definition at line 353 of file ringbuffer.c.
GWENHYWFAR_API void GWEN_RingBuffer_ResetEmptyCounter | ( | GWEN_RINGBUFFER * | rb | ) |
Definition at line 332 of file ringbuffer.c.
GWENHYWFAR_API void GWEN_RingBuffer_ResetFullCounter | ( | GWEN_RINGBUFFER * | rb | ) |
Definition at line 318 of file ringbuffer.c.
GWENHYWFAR_API void GWEN_RingBuffer_ResetMaxUsedBytes | ( | GWEN_RINGBUFFER * | rb | ) |
Resets the counter for the maximum number of bytes stored in the buffer.
Definition at line 290 of file ringbuffer.c.
GWENHYWFAR_API void GWEN_RingBuffer_ResetThroughput | ( | GWEN_RINGBUFFER * | rb | ) |
Resets the buffers throughput counter to zero.
Definition at line 304 of file ringbuffer.c.
GWENHYWFAR_API void GWEN_RingBuffer_SkipBytesRead | ( | GWEN_RINGBUFFER * | rb, | |
uint32_t | psize | |||
) |
Adjusts the internal pointers and statistical data as if GWEN_RingBuffer_ReadBytes had been called. Please note that the size value given here MUST be <= the value returned by GWEN_RingBuffer_GetMaxUnsegmentedRead !
Definition at line 146 of file ringbuffer.c.
References DBG_ERROR, and GWEN_LOGDOMAIN.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API void GWEN_RingBuffer_SkipBytesWrite | ( | GWEN_RINGBUFFER * | rb, | |
uint32_t | psize | |||
) |
Adjusts the internal pointers and statistical data as if GWEN_RingBuffer_WriteBytes had been called. Please note that the size value given here MUST be <= the value returned by GWEN_RingBuffer_GetMaxUnsegmentedWrite !
Definition at line 163 of file ringbuffer.c.
References DBG_ERROR, and GWEN_LOGDOMAIN.
Referenced by GWEN_SyncIo_Buffered_Read().
GWENHYWFAR_API int GWEN_RingBuffer_WriteByte | ( | GWEN_RINGBUFFER * | rb, | |
char | c | |||
) |
Writes a single byte to the ring buffer.
Definition at line 241 of file ringbuffer.c.
References DBG_DEBUG, and GWEN_LOGDOMAIN.
GWENHYWFAR_API int GWEN_RingBuffer_WriteBytes | ( | GWEN_RINGBUFFER * | rb, | |
const char * | buffer, | |||
uint32_t * | size | |||
) |
Writes the given bytes into the ring buffer.
rb | ring buffer | |
buffer | pointer to bytes to write | |
size | pointer to a variable that contains the number of bytes to write. Upon return this variable contains the number of bytes actually copied. |
Definition at line 65 of file ringbuffer.c.
References DBG_DEBUG, and GWEN_LOGDOMAIN.