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

◆ unregister_node()

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

Removes a node from this root node.

Parameters
nodeThe node to unregister

After unregistering, the node will no longer contribute to the root node's output. If called during processing, the operation is deferred until safe.

Definition at line 46 of file RootNode.cpp.

47{
48 if (!node)
49 return;
50
52
53 for (auto& pending_op : m_pending_ops) {
54 bool expected = false;
55 if (pending_op.active.compare_exchange_strong(
56 expected, true,
57 std::memory_order_acquire,
58 std::memory_order_relaxed)) {
59 pending_op.node = node;
60 pending_op.is_addition = false;
61 m_pending_count.fetch_add(1, std::memory_order_relaxed);
62 return;
63 }
64 }
65
66 while (m_is_processing.load(std::memory_order_acquire))
67 m_is_processing.wait(true, std::memory_order_acquire);
68
69 auto it = m_Nodes.begin();
70 while (it != m_Nodes.end()) {
71 if ((*it).get() == node.get()) {
72 it = m_Nodes.erase(it);
73 break;
74 }
75 ++it;
76 }
77
78 node->reset_processed_state();
79
80 uint32_t flag = node->m_state.load();
81 flag &= ~static_cast<uint32_t>(NodeState::PENDING_REMOVAL);
82 flag &= ~static_cast<uint32_t>(NodeState::ACTIVE);
83 flag |= static_cast<uint32_t>(NodeState::INACTIVE);
84 atomic_set_flag_strong(node->m_state, static_cast<NodeState>(flag));
85}
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:209
NodeState
Represents the processing state of a node in the audio graph.
Definition NodeSpec.hpp:43
@ ACTIVE
Engine is processing this node.
Definition NodeSpec.hpp:45
@ INACTIVE
Engine is not processing this node.
Definition NodeSpec.hpp:44
@ PENDING_REMOVAL
Node is marked for removal.
Definition NodeSpec.hpp:46
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
Definition NodeUtils.cpp:94
void atomic_set_flag_strong(std::atomic< NodeState > &flag, const NodeState &desired)
Atomically sets a node state flag to a specific value.
Definition NodeUtils.cpp:88

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

Referenced by MayaFlux::Kriya::TemporalActivation::cleanup_current_operation(), and terminate_all_nodes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: