|
MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
|
| auto MayaFlux::Memory::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.
Retries the read up to max_attempts times if a concurrent write is detected. On each attempt the functor is called with no arguments; its return value is forwarded on success.
Returns std::nullopt if max_attempts is exhausted without a clean read. Callers in frame loops should treat nullopt as "use previous frame" rather than blocking.
The functor must be callable with no arguments and must return a value (or void — see seqlock_read_void for void functors).
| Fn | Callable type, must satisfy std::invocable<Fn>. |
| lock | The Seqlock guarding the data region. |
| max_attempts | Maximum number of read attempts before giving up. 0 means unbounded (spin until clean). |
| fn | Functor that reads and returns the guarded data. |
Definition at line 191 of file SeqLock.hpp.