MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ seqlock_read_void()

template<std::invocable Fn>
requires std::is_void_v<std::invoke_result_t<Fn>>
bool MayaFlux::Memory::seqlock_read_void ( const Seqlock lock,
uint32_t  max_attempts,
Fn &&  fn 
)

Invoke a void read functor under a Seqlock with a bounded retry count.

Same semantics as seqlock_read but for functors with no return value. Returns true if a clean read was achieved within max_attempts, false if the limit was exhausted.

Template Parameters
FnCallable type with void return, must satisfy std::invocable<Fn>.
Parameters
lockThe Seqlock guarding the data region.
max_attemptsMaximum attempts; 0 = unbounded.
fnFunctor that reads the guarded region (side-effect only).
Returns
true on clean read, false on exhaustion.

Definition at line 222 of file SeqLock.hpp.

226{
227 uint32_t attempts = 0;
228 while (max_attempts == 0 || attempts < max_attempts) {
229 uint32_t snap = lock.read_begin();
230 std::invoke(std::forward<Fn>(fn));
231 if (!lock.read_retry(snap))
232 return true;
233 ++attempts;
234 }
235 return false;
236}
uint32_t read_begin() const noexcept
Begin a read: spin until the counter is even, return the snapshot.
Definition SeqLock.hpp:82
bool read_retry(uint32_t snapshot) const noexcept
Check whether a write overlapped the read just completed.
Definition SeqLock.hpp:97

References MayaFlux::Memory::Seqlock::read_begin(), and MayaFlux::Memory::Seqlock::read_retry().

+ Here is the call graph for this function: