The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
Template class for thread safe, half real time safe fifo without explixit locks. More...
Public Member Functions | |
mha_rt_fifo_t () | |
Construct empty fifo. More... | |
~mha_rt_fifo_t () | |
Destructor will delete all data currently in the fifo. More... | |
T * | poll () |
Retrieve the latest element in the Fifo. More... | |
T * | poll_1 () |
Retrieve the next element in the Fifo, if there is one, and mark the previous element as abandonned. More... | |
void | push (T *data) |
Add element to the Fifo. More... | |
Private Member Functions | |
void | remove_abandonned () |
Deletes abandonned elements. More... | |
void | remove_all () |
Deletes all elements. More... | |
Private Attributes | |
mha_rt_fifo_element_t< T > * | root |
The first element in the fifo. Deleting elements starts here. More... | |
mha_rt_fifo_element_t< T > * | current |
The element most recently returned by poll or poll_1. More... | |
Template class for thread safe, half real time safe fifo without explixit locks.
Reading from this fifo is realtime safe, writing to it is not. This fifo is designed for objects that were constructed on the heap. It assumes ownership of these objects and calls delete on them when they are no longer used. Objects remain inside the Fifo while being used by the reader.
A new fifo element is inserted by using push. The push operation is not real time safe, it allocates and deallocates memory. The latest element is retrieved by calling poll. This operation will skip fifo elements if more than one push has been occured since the last poll. To avoid skipping, call the poll_1 operation instead.
|
inline |
Construct empty fifo.
|
inline |
Destructor will delete all data currently in the fifo.
|
inline |
Retrieve the latest element in the Fifo.
Will skip fifo elements if more than one element has been added since last poll invocation. Will return the same element as on last call if no elements have been added in the mean time. Marks former elements as abandonned.
|
inline |
Retrieve the next element in the Fifo, if there is one, and mark the previous element as abandonned.
Else, if there is no newer element, returns the same element as on last poll() or poll_1() invocation.
|
inline |
Add element to the Fifo.
Deletes abandonned elements in the fifo.
data | The new user data to place at the end of the fifo. After this invocation, the fifo is the owner of this object and will delete it when it is no longer used. data must have been allocated on the heap with standard operator new. |
|
inlineprivate |
Deletes abandonned elements.
|
inlineprivate |
Deletes all elements.
|
private |
The first element in the fifo. Deleting elements starts here.
|
private |