MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::ControlValue Class Reference

One pending value, written from any thread and applied once per change by one consumer. More...

#include <ControlValue.hpp>

Inheritance diagram for MayaFlux::ControlValue:
Collaboration diagram for MayaFlux::ControlValue:

Classes

struct  State

Public Member Functions

void assign (const ControlValue &incoming) noexcept
 Takes everything incoming holds, so the next due() is true.
 ControlValue ()=default
 ControlValue (const ControlValue &other) noexcept
 ControlValue (ControlValue &&other) noexcept
template<typename T>
requires is_value<T>
 ControlValue (T value) noexcept
bool due () const noexcept
 True when a consumer should apply this value now.
bool has_value () const noexcept
 True once a value was given.
template<typename T>
requires is_value<T>
void observe (T actual) noexcept
 Shows the value the owner really has.
 operator double () const noexcept
ControlValue & operator= (const ControlValue &other) noexcept
ControlValue & operator= (ControlValue &&other) noexcept
template<typename T = double>
requires is_value<T>
std::optional< T > pending () noexcept
 The value to apply now as type T, or nullopt when nothing is due.
void refresh () noexcept
 Nothing to read for a plain value.
void settle () noexcept
 Marks the current value as applied.
template<typename T>
requires is_value<T>
T value () const noexcept
 The value as type T, which must be the type it was set with.
double value () const noexcept
 The value as a double.
size_t width () const noexcept
 Components held: 0 when empty, 1 for a number, flag or enum, 2 to 4 for a vector, 6 for a box.
 ~ControlValue ()=default

Static Public Attributes

template<typename T>
static constexpr bool is_box
template<typename T>
static constexpr bool is_value = std::is_arithmetic_v<T> || std::is_enum_v<T> || is_vector<T> || is_box<T>
template<typename T>
static constexpr bool is_vector

Protected Member Functions

bool changed () const noexcept
void set_blank () noexcept
 Marks the slot set with one zero lane and leaves it clean.
void set_scalar (double value) noexcept

Static Protected Member Functions

template<typename T>
static constexpr uint8_t width_of () noexcept

Static Protected Attributes

static constexpr size_t k_lanes = 6

Private Member Functions

void copy_state (const ControlValue &other) noexcept
template<typename T>
std::array< double, k_lanes > lanes_for () const noexcept
State read_state () const noexcept
void store (const std::array< double, k_lanes > &lanes, uint8_t width, bool set) noexcept

Static Private Member Functions

template<typename T>
static T from_lanes (const std::array< double, k_lanes > &lanes) noexcept
template<typename T>
static std::array< double, k_lanes > to_lanes (T value) noexcept

Private Attributes

std::atomic< bool > m_dirty { false }
std::array< std::atomic< double >, k_lanes > m_lane {}
Memory::Seqlock m_lock
std::atomic< bool > m_set { false }
std::atomic< uint8_t > m_width { 0 }

Detailed Description

One pending value, written from any thread and applied once per change by one consumer.

Holds a number, a bool, an enum, a float glm vector or a box (a struct of exactly a glm::vec3 min and a glm::vec3 max) as six double lanes, a width and flags. Numbers are atomic, and a vector is written and read under a sequence lock, so it is never seen half written. A value is never lost to a race, only possibly applied twice with the same content. It holds one pending value, so a later value replaces one that no block has applied yet. Integers are carried exactly up to 2^53. A read of another type than was set finds nothing.

Definition at line 23 of file ControlValue.hpp.


The documentation for this class was generated from the following file: