|
MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
|
Policy-driven unified circular buffer implementation. More...
#include <RingBuffer.hpp>
Inheritance diagram for MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >:
Collaboration diagram for MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >:Public Types | |
| using | value_type = T |
| using | storage_type = StoragePolicy |
| using | reference = T & |
| using | const_reference = const T & |
Public Member Functions | |
| RingBuffer (size_t initial_capacity=64) | |
| Construct ring buffer with runtime capacity (DynamicStorage only) | |
| RingBuffer ()=default | |
| Default construct ring buffer (FixedStorage only) Capacity determined by template parameter. | |
| bool | push (const T &value) noexcept(is_lock_free) |
| Push element into buffer. | |
| std::optional< T > | pop () noexcept(is_lock_free) |
| Pop element from buffer. | |
| const_reference | peek_newest () const |
| Peek at newest element without removing. | |
| const_reference | peek_oldest () const |
| Peek at oldest element without removing. | |
| const_reference | operator[] (size_t index) const |
| Access element by index (delay line style) | |
| void | overwrite_newest (const T &value) |
| Overwrite newest element without advancing write position. | |
| std::span< T > | linearized_view () const |
| Get linearized view of buffer contents. | |
| std::span< T > | linearized_view_mut () |
| Get mutable linearized view for modification. | |
| std::vector< T > | snapshot () const |
| Thread-safe snapshot of buffer contents. | |
| bool | empty () const noexcept |
| Check if buffer is empty. | |
| size_t | size () const noexcept |
| Get approximate element count. | |
| size_t | capacity () const noexcept |
| Get buffer capacity. | |
| void | resize (size_t new_capacity) |
| Resize buffer capacity (DynamicStorage only) | |
| void | reset () noexcept |
| Clear buffer contents and reset indices. | |
Static Public Attributes | |
| static constexpr bool | is_lock_free = ConcurrencyPolicy::is_thread_safe |
| static constexpr bool | is_resizable = StoragePolicy::is_resizable |
| static constexpr bool | is_delay_line = AccessPattern::push_front |
Private Types | |
| using | State = typename ConcurrencyPolicy::template State< T, StoragePolicy > |
Private Member Functions | |
| bool | push_lockfree (const T &value) noexcept |
| std::optional< T > | pop_lockfree () noexcept |
| bool | push_singlethread (const T &value) noexcept |
| std::optional< T > | pop_singlethread () noexcept |
Private Attributes | |
| StoragePolicy | m_storage |
| State | m_state |
| std::vector< T > | m_linearized |
Policy-driven unified circular buffer implementation.
Provides a single, flexible ring buffer that adapts to different use cases through compile-time policy selection. Policies control storage allocation, thread safety, and access patterns independently.
Design Philosophy:
Policy Dimensions:
Common Configurations:
Migration from Legacy Implementations:
| T | Element type |
| StoragePolicy | FixedStorage<T,N> or DynamicStorage<T> |
| ConcurrencyPolicy | LockFreePolicy or SingleThreadedPolicy |
| AccessPattern | QueueAccess or HistoryBufferAccess |
Definition at line 666 of file RingBuffer.hpp.