A single-thread circular history whose complete oldest-to-newest window is always physically contiguous. More...
#include <mirrored_history_buffer.hpp>
Public Member Functions | |
| MirroredHistoryBuffer ()=default | |
| MirroredHistoryBuffer (const MirroredHistoryBuffer &)=default | |
| MirroredHistoryBuffer & | operator= (const MirroredHistoryBuffer &)=default |
| MirroredHistoryBuffer (MirroredHistoryBuffer &&other) noexcept | |
| MirroredHistoryBuffer & | operator= (MirroredHistoryBuffer &&other) noexcept |
| bool | prepare (std::size_t capacity) |
| Allocates control-thread storage transactionally. | |
| void | reset () noexcept |
| void | push (SampleType sample) noexcept |
| std::span< const SampleType > | window () const noexcept |
| The view remains memory-valid until prepare(), but consume it before the next push() or reset() because those calls change its contents and may change which physical span represents the ordered history. | |
| std::size_t | capacity () const noexcept |
| bool | empty () const noexcept |
A single-thread circular history whose complete oldest-to-newest window is always physically contiguous.
prepare() allocates two copies of the requested capacity. Each push() writes the new sample into both mirrors and advances one bounded cursor, so its cost does not depend on wrap position. window() then returns the last capacity() samples ordered oldest to newest without a copy or modulo walk. Unfilled positions and positions restored by reset() contain zeroes.
This is DSP-local history, not a queue and not a synchronization primitive. It is not safe for concurrent producer/consumer access. After prepare(), push(), window(), reset(), and the accessors allocate no memory.
|
default |
|
default |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
default |
|
inlinenoexcept |
|
inline |
Allocates control-thread storage transactionally.
Returns false when doubling the requested capacity would overflow size_t; the existing history remains unchanged. Allocation failure follows std::vector's build-mode policy (exception or termination).
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |