Beamlib 3.1.1
This is the Beam C++ class library.
|
This class implements a thread safe FIFO buffer using a binary sized circular memory. More...
#include <BFifoCirc.h>
Public Types | |
enum | { defaultSize = 1024 } |
Public Member Functions | |
BFifoCirc (uint32_t size=defaultSize) | |
~BFifoCirc () | |
uint32_t | size () |
Return the buffers actual size. More... | |
void | clear () |
Clear all of the data in the buffer. More... | |
uint32_t | writeAvailable () |
Returns the space available to write. More... | |
BError | writeWaitAvailable (uint32_t numFifoSamples) |
Wait for the given number of samples. More... | |
BError | write (const Type *data, uint32_t numFifoSamples) |
Writes the data to the buffer. Blocks until complete. More... | |
Type * | writeData () |
Return a pointer to the current start of the buffer. More... | |
void | writeDone (uint32_t numFifoSamples) |
Update the write pointer. More... | |
uint32_t | readAvailable () |
Returns the number of bytes of data available. More... | |
BError | readWaitAvailable (uint32_t numFifoSamples) |
Wait for given number of samples. More... | |
BError | read (Type *data, uint32_t numFifoSamples) |
Type * | readData () |
Pointer to raw data. More... | |
BError | readDone (uint32_t numFifoSamples) |
Updates read pointer. More... | |
Type & | operator[] (int pos) |
Direct access to read samples in buffer. More... | |
Protected Member Functions | |
BError | mapCircularBuffer (uint32_t size) |
void | unmapCircularBuffer () |
Protected Attributes | |
BMutex | olock |
uint32_t | ovmSize |
uint32_t | osize |
Type * | odata |
BFifoCircPos | owritePos |
Current write position. More... | |
BCondValue | owriteNumFifoSamples |
The number of samples in the FIFO. More... | |
BFifoCircPos | oreadPos |
Current read position. More... | |
This class implements a thread safe FIFO buffer using a binary sized circular memory.
This class stores data in a ring buffer where the actual buffer is circular. It can store up to (size - 1) items. It has separate read and write pointers. These are thread safe. Note the read and write routines do not bounds check the Fifo. You have to use readAvailable()/writeAvailable() functions to check how much can be read/written before performing the reads or writes. The CPU's MMU is used to create a binary sized memory area that wrapps around on itself.
BFifoCirc< Type >::BFifoCirc | ( | uint32_t | size = defaultSize | ) |
uint32_t BFifoCirc< Type >::size | ( | ) |
Return the buffers actual size.
void BFifoCirc< Type >::clear | ( | ) |
Clear all of the data in the buffer.
uint32_t BFifoCirc< Type >::writeAvailable | ( | ) |
Returns the space available to write.
Wait for the given number of samples.
BError BFifoCirc< Type >::write | ( | const Type * | data, |
uint32_t | numFifoSamples | ||
) |
Writes the data to the buffer. Blocks until complete.
Type * BFifoCirc< Type >::writeData | ( | ) |
Return a pointer to the current start of the buffer.
void BFifoCirc< Type >::writeDone | ( | uint32_t | numFifoSamples | ) |
Update the write pointer.
uint32_t BFifoCirc< Type >::readAvailable | ( | ) |
Returns the number of bytes of data available.
Wait for given number of samples.
Type * BFifoCirc< Type >::readData | ( | ) |
Pointer to raw data.
Updates read pointer.
Type & BFifoCirc< Type >::operator[] | ( | int | pos | ) |
Direct access to read samples in buffer.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Current write position.
|
protected |
The number of samples in the FIFO.
|
protected |
Current read position.