The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
mha_fifo_lw_t< T > Class Template Reference

This FIFO uses locks to synchronize access. More...

Inheritance diagram for mha_fifo_lw_t< T >:
Inheritance graph

Public Member Functions

virtual void write (const T *data, unsigned count)
 write specified ammount of data to the fifo. More...
 
virtual void read (T *buf, unsigned count)
 read data from fifo. More...
 
 mha_fifo_lw_t (unsigned max_fill_count)
 Create FIFO with fixed buffer size. More...
 
virtual ~mha_fifo_lw_t ()
 release synchronization object More...
 
virtual void set_error (unsigned index, MHA_Error *error)
 Process waiting for more data or space should bail out, throwing this error. More...
 
- Public Member Functions inherited from mha_fifo_t< T >
virtual unsigned get_fill_count () const
 Read-only access to fill_count. More...
 
virtual unsigned get_available_space () const
 Read-only access to available_space. More...
 
virtual unsigned get_max_fill_count () const
 The capacity of this fifo. More...
 
 mha_fifo_t (unsigned max_fill_count, const T &t=T())
 Create FIFO with fixed buffer size, where all (initially unused) instances of T are initialized as copies of t. More...
 
virtual ~mha_fifo_t ()=default
 Make destructor virtual. More...
 
 mha_fifo_t (const mha_fifo_t &)=delete
 Copy constructor. More...
 
 mha_fifo_t (mha_fifo_t &&)=delete
 Move constructor. More...
 
mha_fifo_t< T > & operator= (const mha_fifo_t< T > &)=delete
 Assignment operator. More...
 
mha_fifo_t< T > & operator= (mha_fifo_t< T > &&)=delete
 Move assignment operator. More...
 

Private Attributes

mha_fifo_thread_platform_tsync
 platform specific thread synchronization More...
 
MHA_Errorerror [2]
 If waiting for synchronization should be aborted then exception to be thrown by reader process (index 0) or writer process (index 1) has to be placed here. More...
 

Additional Inherited Members

- Public Types inherited from mha_fifo_t< T >
typedef std::vector< T >::value_type value_type
 The data type exchanged by this fifo. More...
 
- Protected Member Functions inherited from mha_fifo_t< T >
void clear ()
 Empty the fifo at once. More...
 
const T * get_write_ptr () const
 read-only access to the write pointer for derived classes More...
 
const T * get_read_ptr () const
 read-only access to read pointer for derived classes More...
 
unsigned get_fill_count (const T *wp, const T *rp) const
 Compute fill count from given write pointer and read pointer. More...
 

Detailed Description

template<class T>
class mha_fifo_lw_t< T >

This FIFO uses locks to synchronize access.

Reading and writing can block until the operation can be executed.

Constructor & Destructor Documentation

◆ mha_fifo_lw_t()

template<class T >
mha_fifo_lw_t< T >::mha_fifo_lw_t ( unsigned  max_fill_count)
explicit

Create FIFO with fixed buffer size.

◆ ~mha_fifo_lw_t()

template<class T >
mha_fifo_lw_t< T >::~mha_fifo_lw_t
virtual

release synchronization object

Member Function Documentation

◆ write()

template<class T >
void mha_fifo_lw_t< T >::write ( const T *  data,
unsigned  count 
)
virtual

write specified ammount of data to the fifo.

If there is not enough space, then wait for more space.

Parameters
dataPointer to source data.
countNumber of instances to copy.
Exceptions
MHA_Errorwhen detecting a deadlock situation.

Reimplemented from mha_fifo_t< T >.

◆ read()

template<class T >
void mha_fifo_lw_t< T >::read ( T *  buf,
unsigned  count 
)
virtual

read data from fifo.

If there is not enough data, then wait for more data.

Parameters
bufPointer to the target buffer.
countNumber of instances to copy.
Exceptions
MHA_Errorwhen detecting a deadlock situation.

Reimplemented from mha_fifo_t< T >.

◆ set_error()

template<class T >
void mha_fifo_lw_t< T >::set_error ( unsigned  index,
MHA_Error error 
)
virtual

Process waiting for more data or space should bail out, throwing this error.

Parameters
indexUse 0 for terminating reader, 1 for terminating writer.
errorMHA_Error to be thrown

Member Data Documentation

◆ sync

template<class T >
mha_fifo_thread_platform_t* mha_fifo_lw_t< T >::sync
private

platform specific thread synchronization

◆ error

template<class T >
MHA_Error* mha_fifo_lw_t< T >::error[2]
private

If waiting for synchronization should be aborted then exception to be thrown by reader process (index 0) or writer process (index 1) has to be placed here.


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