50 [[nodiscard]]
bool has_value() const noexcept {
return m_set.load(std::memory_order_acquire); }
53 [[nodiscard]] std::shared_ptr<const T>
value() const noexcept
55 const auto view =
m_cell.read();
56 return view ? *view :
nullptr;
60 [[nodiscard]]
bool due() const noexcept
66 void settle() noexcept {
m_dirty.exchange(
false, std::memory_order_acq_rel); }
69 [[nodiscard]] std::shared_ptr<const T>
pending() noexcept
80 m_cell.publish(std::make_shared<const T>(std::move(
value)));
81 m_set.store(
true, std::memory_order_release);
82 m_dirty.store(
true, std::memory_order_release);
91 m_set.store(
true, std::memory_order_release);
93 m_dirty.store(
true, std::memory_order_release);
106 m_set.store(other.
m_set.load(std::memory_order_acquire), std::memory_order_release);
107 m_dirty.store(other.
m_dirty.load(std::memory_order_acquire), std::memory_order_release);
std::atomic< bool > m_dirty
ControlSnapshot()=default
ControlSnapshot(T initial)
std::shared_ptr< const T > value() const noexcept
The current value, or null when none was given.
ControlSnapshot(const ControlSnapshot &other)
void assign(const ControlSnapshot &incoming)
Takes the value incoming holds, so the next due() is true.
void refresh() noexcept
Nothing to read from a source.
void set(T value)
Replaces the value, so the next due() is true.
ControlSnapshot(ControlSnapshot &&other)
ControlSnapshot & operator=(ControlSnapshot &&other)
bool has_value() const noexcept
True once a value was given.
ControlSnapshot & operator=(const ControlSnapshot &other)
Memory::SnapshotCell< std::shared_ptr< const T > > m_cell
bool due() const noexcept
True when a consumer should apply this value now.
void settle() noexcept
Marks the current value as applied.
std::atomic< bool > m_set
std::shared_ptr< const T > pending() noexcept
The value to apply now, or null when nothing is due.
void copy_state(const ControlSnapshot &other)
~ControlSnapshot()=default
Guard read() const noexcept
Pins the current snapshot.
Lock-free cell holding one immutable snapshot of a value, read without blocking.
Main namespace for the Maya Flux audio engine.