|
MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
|
Single-writer multiple-reader sequence lock for fixed-size data regions. More...
#include <SeqLock.hpp>
Collaboration diagram for MayaFlux::Memory::Seqlock:Public Member Functions | |
| void | begin_write () noexcept |
| Begin a write: advances the counter to an odd value. | |
| void | end_write () noexcept |
| End a write: advances the counter back to an even value. | |
| Seqlock & | operator= (const Seqlock &)=delete |
| Seqlock & | operator= (Seqlock &&)=delete |
| uint32_t | read_begin () const noexcept |
| Begin a read: spin until the counter is even, return the snapshot. | |
| bool | read_retry (uint32_t snapshot) const noexcept |
| Check whether a write overlapped the read just completed. | |
| Seqlock () noexcept=default | |
| Seqlock (const Seqlock &)=delete | |
| Seqlock (Seqlock &&)=delete | |
| uint32_t | sequence () const noexcept |
| Return the raw sequence counter value. | |
| ~Seqlock ()=default | |
Private Attributes | |
| std::atomic< uint32_t > | m_seq { 0U } |
Single-writer multiple-reader sequence lock for fixed-size data regions.
Protects a data region that is written infrequently and read frequently. Readers never block writers; a reader that observes a write in progress simply retries. Writers are serialized externally (e.g. by the container's existing state machine or a higher-level mutex on the write path only).
Sequence counter convention: even — data is stable, safe to read odd — write in progress, readers must retry
Usage — writer side:
Usage — reader side (unbounded):
Usage — reader side (bounded, preferred in frame loops):
Alignment to a cache line prevents false sharing when multiple Seqlock instances are stored in a contiguous array (e.g. one per texture layer).
Definition at line 44 of file SeqLock.hpp.