arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Modules Pages
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.
 
T & back ()
 Provides the last element.
 
Iterator begin ()
 
bool clear ()
 
bool empty ()
 
Iterator end ()
 
bool erase (Iterator it)
 
T & front ()
 Provides the first element.
 
bool insert (Iterator it, const T &data)
 
T & operator[] (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_t > record_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.


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