LibBeamApi  1.3.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
BFifo< Type > Class Template Reference

This class implements a thread safe FIFO buffer. More...

#include <BFifo.h>

Public Types

enum  { defaultSize = 1024 }
 

Public Member Functions

 BFifo (uint32_t size=defaultSize)
 
 ~BFifo ()
 
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...
 

Private Member Functions

BError mapCircularBuffer (uint32_t size)
 
void unmapCircularBuffer ()
 

Private Attributes

BMutex olock
 
uint32_t ovmSize
 
uint32_t osize
 
Type * odata
 
BFifoPos owritePos
 Current write position. More...
 
BCondValue owriteNumFifoSamples
 The number of samples in the FIFO. More...
 
BFifoPos oreadPos
 Current read position. More...
 

Detailed Description

template<class Type>
class BFifo< Type >

This class implements a thread safe FIFO buffer.

Member Enumeration Documentation

template<class Type >
anonymous enum
Enumerator
defaultSize 

Constructor & Destructor Documentation

template<class Type >
BFifo< Type >::BFifo ( uint32_t  size = defaultSize)
template<class Type >
BFifo< Type >::~BFifo ( )

Member Function Documentation

template<class Type >
void BFifo< Type >::clear ( )

Clear all of the data in the buffer.

template<class Type >
BError BFifo< Type >::mapCircularBuffer ( uint32_t  size)
private
template<class Type >
Type& BFifo< Type >::operator[] ( int  pos)

Direct access to read samples in buffer.

template<class Type >
BError BFifo< Type >::read ( Type *  data,
uint32_t  numFifoSamples 
)
template<class Type >
uint32_t BFifo< Type >::readAvailable ( )

Returns the number of bytes of data available.

template<class Type >
Type* BFifo< Type >::readData ( )

Pointer to raw data.

template<class Type >
BError BFifo< Type >::readDone ( uint32_t  numFifoSamples)

Updates read pointer.

template<class Type >
BError BFifo< Type >::readWaitAvailable ( uint32_t  numFifoSamples)

Wait for given number of samples.

template<class Type >
uint32_t BFifo< Type >::size ( )

Return the buffers actual size.

template<class Type >
void BFifo< Type >::unmapCircularBuffer ( )
private
template<class Type >
BError BFifo< Type >::write ( const Type *  data,
uint32_t  numFifoSamples 
)

Writes the data to the buffer. Blocks until complete.

template<class Type >
uint32_t BFifo< Type >::writeAvailable ( )

Returns the space available to write.

template<class Type >
Type* BFifo< Type >::writeData ( )

Return a pointer to the current start of the buffer.

template<class Type >
void BFifo< Type >::writeDone ( uint32_t  numFifoSamples)

Update the write pointer.

template<class Type >
BError BFifo< Type >::writeWaitAvailable ( uint32_t  numFifoSamples)

Wait for the given number of samples.

Member Data Documentation

template<class Type >
Type* BFifo< Type >::odata
private
template<class Type >
BMutex BFifo< Type >::olock
private
template<class Type >
BFifoPos BFifo< Type >::oreadPos
private

Current read position.

template<class Type >
uint32_t BFifo< Type >::osize
private
template<class Type >
uint32_t BFifo< Type >::ovmSize
private
template<class Type >
BCondValue BFifo< Type >::owriteNumFifoSamples
private

The number of samples in the FIFO.

template<class Type >
BFifoPos BFifo< Type >::owritePos
private

Current write position.


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