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

◆ register_node()

void MayaFlux::Nodes::RootNode::register_node ( const std::shared_ptr< Node > &  node)

Adds a node to this root node.

Parameters
nodeThe node to register

Registered nodes will be processed when the root node's process() method is called, and their outputs will be combined together. If called during processing, the operation is deferred until safe.

Definition at line 16 of file RootNode.cpp.

17{
18 if (m_is_processing.load(std::memory_order_acquire)) {
19 if (m_Nodes.end() != std::ranges::find(m_Nodes, node)) {
20 uint32_t state = node->m_state.load();
21 if (state & Utils::NodeState::INACTIVE) {
24 }
25 return;
26 }
27
28 for (auto& m_pending_op : m_pending_ops) {
29 bool expected = false;
30 if (m_pending_op.active.compare_exchange_strong(
31 expected, true,
32 std::memory_order_acquire,
33 std::memory_order_relaxed)) {
34 m_pending_op.node = node;
37 m_pending_count.fetch_add(1, std::memory_order_relaxed);
38 return;
39 }
40 }
41
42 while (m_is_processing.load(std::memory_order_acquire)) {
43 m_is_processing.wait(true, std::memory_order_acquire);
44 }
45 }
46
47 m_Nodes.push_back(node);
48 uint32_t state = node->m_state.load();
50}
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:159
std::atomic< bool > m_is_processing
Flag indicating if the root node is currently processing nodes.
Definition RootNode.hpp:170
struct MayaFlux::Nodes::RootNode::PendingOp m_pending_ops[2048]
std::atomic< uint32_t > m_pending_count
Counter tracking the number of pending operations.
Definition RootNode.hpp:207
void atomic_add_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically adds a flag to a node state.
Definition NodeUtils.cpp:96
void atomic_remove_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically removes a flag from a node state.
@ INACTIVE
Engine is not processing this node.
Definition Utils.hpp:29
@ ACTIVE
Engine is processing this node.
Definition Utils.hpp:30

References MayaFlux::Utils::ACTIVE, MayaFlux::Nodes::atomic_add_flag(), MayaFlux::Nodes::atomic_remove_flag(), MayaFlux::Utils::INACTIVE, m_is_processing, m_Nodes, m_pending_count, and m_pending_ops.

+ Here is the call graph for this function: