MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Memory::SeqlockArray Class Reference

Indexed collection of independent, equal-ranked Seqlock instances. More...

#include <SeqLock.hpp>

+ Collaboration diagram for MayaFlux::Memory::SeqlockArray:

Public Member Functions

SeqlockArrayoperator= (const SeqlockArray &)=delete
 
SeqlockArrayoperator= (SeqlockArray &&)=delete
 
const Seqlockoperator[] (size_t i) const noexcept
 Access the Seqlock at index i (const overload).
 
Seqlockoperator[] (size_t i) noexcept
 Access the Seqlock at index i.
 
void resize (size_t n)
 Replace the slot array with n default-constructed Seqlock instances.
 
 SeqlockArray ()=default
 
 SeqlockArray (const SeqlockArray &)=delete
 
 SeqlockArray (SeqlockArray &&)=delete
 
 SeqlockArray (size_t n)
 
size_t size () const noexcept
 Number of slots.
 
 ~SeqlockArray ()=default
 

Private Attributes

std::vector< std::unique_ptr< Seqlock > > m_slots
 

Detailed Description

Indexed collection of independent, equal-ranked Seqlock instances.

Manages N independently lockable Seqlock slots with no privileged index. Suitable wherever a container holds N equal data slots (layers, channels, ring positions) that may be written and read independently and concurrently.

Slots are heap-allocated individually via unique_ptr to satisfy alignas(64) without violating the non-copyable / non-movable contract of Seqlock.

resize() is not safe to call concurrently with any read or write operation on this instance.

SeqlockArray locks(num_slots);
// writer
{
SeqlockWriteGuard g(locks[slot]);
std::ranges::copy(src, dst.begin());
}
// reader
auto result = seqlock_read(locks[slot], 8, [&]{ return read_slot(slot); });
Indexed collection of independent, equal-ranked Seqlock instances.
Definition SeqLock.hpp:269
RAII guard that brackets a Seqlock write region.
Definition SeqLock.hpp:136
auto seqlock_read(const Seqlock &lock, uint32_t max_attempts, Fn &&fn) -> std::optional< std::invoke_result_t< Fn > >
Invoke a read functor under a Seqlock with a bounded retry count.
Definition SeqLock.hpp:191

Definition at line 269 of file SeqLock.hpp.


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