Audio Processing Framework (APF) version 0.5.0
Public Member Functions | List of all members
apf::LockFreeFifo< T * > Class Template Reference

Lock-free first-in-first-out (FIFO) queue. More...

#include <apf/lockfreefifo.h>

Inheritance diagram for apf::LockFreeFifo< T * >:
Inheritance graph
[legend]

Public Member Functions

 LockFreeFifo (size_t size)
 ctor. More...
 
bool push (T *item)
 Add an item to the queue. More...
 
T * pop ()
 Get an item and remove it from the queue. More...
 
bool empty () const
 Check if queue is empty. More...
 

Detailed Description

template<typename T>
class apf::LockFreeFifo< T * >

Lock-free first-in-first-out (FIFO) queue.

It is thread-safe for single reader/single writer access. One thread may use push() to en-queue items and another thread may use pop() to de-queue items.

Note
This FIFO queue is implemented as a ring buffer.
This class is somehow related to the JACK ringbuffer implementation: http://jackaudio.org/files/docs/html/ringbuffer_8h.html

Definition at line 51 of file lockfreefifo.h.

Constructor & Destructor Documentation

◆ LockFreeFifo()

template<typename T >
apf::LockFreeFifo< T * >::LockFreeFifo ( size_t  size)
explicit

ctor.

Parameters
sizedesired ring buffer size, gets rounded up to the next power of 2.

Definition at line 72 of file lockfreefifo.h.

Member Function Documentation

◆ push()

template<typename T >
bool apf::LockFreeFifo< T * >::push ( T *  item)

Add an item to the queue.

Parameters
itempointer to an item to be added.
Returns
true on success, false if queue is full.
Attention
You have to check the return value to be sure the item has actually been added.

Definition at line 88 of file lockfreefifo.h.

◆ pop()

template<typename T >
T * apf::LockFreeFifo< T * >::pop

Get an item and remove it from the queue.

Returns
Pointer to the item, 0 if queue is empty.

Definition at line 119 of file lockfreefifo.h.

◆ empty()

template<typename T >
bool apf::LockFreeFifo< T * >::empty

Check if queue is empty.

Returns
true if empty.

Definition at line 139 of file lockfreefifo.h.


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