arduino-audio-tools
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ListLockFree< T > Class Template Reference

Lock-free double linked list using atomic operations. More...

#include <ListLockFree.h>

Classes

class  Iterator
 
struct  Node
 

Public Member Functions

 ListLockFree (Allocator &allocator=DefaultAllocator)
 Default constructor.
 
 ListLockFree (const ListLockFree &ref)
 Copy constructor (not thread-safe for the source list)
 
template<size_t N>
 ListLockFree (const T(&a)[N], Allocator &allocator=DefaultAllocator)
 Constructor using array.
 
 ~ListLockFree ()
 
Tback ()
 Provides the last element.
 
Iterator begin ()
 
bool clear ()
 
bool empty ()
 
Iterator end ()
 
bool erase (Iterator it)
 
Tfront ()
 Provides the first element.
 
bool insert (Iterator it, const T &data)
 
Toperator[] (int index)
 
bool pop_back ()
 
bool pop_back (T &data)
 
bool pop_front ()
 
bool pop_front (T &data)
 
bool push_back (const T &data)
 
bool push_front (const T &data)
 
Iterator rbegin ()
 
Iterator rend ()
 
void setAllocator (Allocator &allocator)
 
size_t size ()
 
bool swap (ListLockFree< T > &ref)
 

Protected Member Functions

NodecreateNode ()
 
void deleteNode (Node *p_delete)
 
void link ()
 

Protected Attributes

Node first
 
Node last
 
Allocatorp_allocator = &DefaultAllocator
 
std::atomic< size_trecord_count {0}
 

Friends

class Iterator
 

Detailed Description

template<class T>
class audio_tools::ListLockFree< T >

Lock-free double linked list using atomic operations.

Author
Phil Schatzmann
Template Parameters
T

This implementation provides thread-safe operations without using locks. It uses atomic pointers and compare-and-swap operations for synchronization. Note: Some operations like size() may not be perfectly consistent in highly concurrent scenarios but will be eventually consistent.

Constructor & Destructor Documentation

◆ ListLockFree() [1/3]

template<class T >
ListLockFree ( Allocator allocator = DefaultAllocator)
inline

Default constructor.

◆ ListLockFree() [2/3]

template<class T >
ListLockFree ( const ListLockFree< T > &  ref)
inline

Copy constructor (not thread-safe for the source list)

◆ ListLockFree() [3/3]

template<class T >
template<size_t N>
ListLockFree ( const T(&)  a[N],
Allocator allocator = DefaultAllocator 
)
inline

Constructor using array.

◆ ~ListLockFree()

template<class T >
~ListLockFree ( )
inline

Member Function Documentation

◆ back()

template<class T >
T & back ( )
inline

Provides the last element.

◆ begin()

template<class T >
Iterator begin ( )
inline

◆ clear()

template<class T >
bool clear ( )
inline

◆ createNode()

template<class T >
Node * createNode ( )
inlineprotected

◆ deleteNode()

template<class T >
void deleteNode ( Node p_delete)
inlineprotected

◆ empty()

template<class T >
bool empty ( )
inline

◆ end()

template<class T >
Iterator end ( )
inline

◆ erase()

template<class T >
bool erase ( Iterator  it)
inline

◆ front()

template<class T >
T & front ( )
inline

Provides the first element.

◆ insert()

template<class T >
bool insert ( Iterator  it,
const T data 
)
inline

◆ link()

template<class T >
void link ( )
inlineprotected

◆ operator[]()

template<class T >
T & operator[] ( int  index)
inline

◆ pop_back() [1/2]

template<class T >
bool pop_back ( )
inline

◆ pop_back() [2/2]

template<class T >
bool pop_back ( T data)
inline

◆ pop_front() [1/2]

template<class T >
bool pop_front ( )
inline

◆ pop_front() [2/2]

template<class T >
bool pop_front ( T data)
inline

◆ push_back()

template<class T >
bool push_back ( const T data)
inline

◆ push_front()

template<class T >
bool push_front ( const T data)
inline

◆ rbegin()

template<class T >
Iterator rbegin ( )
inline

◆ rend()

template<class T >
Iterator rend ( )
inline

◆ setAllocator()

template<class T >
void setAllocator ( Allocator allocator)
inline

◆ size()

template<class T >
size_t size ( )
inline

◆ swap()

template<class T >
bool swap ( ListLockFree< T > &  ref)
inline

Friends And Related Symbol Documentation

◆ Iterator

template<class T >
friend class Iterator
friend

Member Data Documentation

◆ first

template<class T >
Node first
protected

◆ last

template<class T >
Node last
protected

◆ p_allocator

template<class T >
Allocator* p_allocator = &DefaultAllocator
protected

◆ record_count

template<class T >
std::atomic<size_t> record_count {0}
protected

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