Lock-free reader/writer for reading multi-field structs as consistent snapshots.
More...
template<typename T>
class pulp::runtime::SeqLock< T >
Lock-free reader/writer for reading multi-field structs as consistent snapshots.
Use when a single writer (e.g., the audio thread) publishes a struct that multiple readers need to consume atomically. Readers spin-retry if the data was modified during their read, guaranteeing coherence without mutexes.
- Template Parameters
-
| T | Must be trivially copyable. |
struct Transport { double tempo; double beat_pos; int time_sig_num; };
transport.
write({120.0, 4.5, 4});
auto snap = transport.
read();
Lock-free reader/writer for reading multi-field structs as consistent snapshots.
Definition seqlock.hpp:42
void write(const T &value)
Publish a new value.
Definition seqlock.hpp:59
T read() const
Read a consistent snapshot.
Definition seqlock.hpp:71
- Note
- Safe on ARM and x86. Uses acquire/release ordering internally.
-
Only one writer thread is allowed. Multiple concurrent readers are safe.