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

◆ process_pending_operations()

void MayaFlux::Nodes::RootNode::process_pending_operations ( )
private

Processes any pending node registration/unregistration operations.

This method is called after the processing cycle completes to handle any node registration or unregistration requests that came in during processing. It ensures that node collection modifications happen safely between processing cycles, maintaining audio continuity while allowing dynamic changes to the node graph.

Definition at line 164 of file RootNode.cpp.

165{
166 m_pending_ops.drain([this](PendingOp&& op) {
167 if (op.is_addition) {
168 if (m_Nodes.end() == std::ranges::find(m_Nodes, op.node)) {
169 m_Nodes.push_back(op.node);
170 uint32_t state = op.node->m_state.load();
171 state &= ~static_cast<uint32_t>(NodeState::INACTIVE);
172 state |= static_cast<uint32_t>(NodeState::ACTIVE);
173 atomic_set_flag_strong(op.node->m_state, static_cast<NodeState>(state));
174 }
175 } else {
176 auto it = std::ranges::find(m_Nodes, op.node);
177 if (it != m_Nodes.end()) {
178 m_Nodes.erase(it);
179 }
180 op.node->reset_processed_state();
181 uint32_t state = op.node->m_state.load();
182 state &= ~static_cast<uint32_t>(NodeState::PENDING_REMOVAL);
183 state &= ~static_cast<uint32_t>(NodeState::ACTIVE);
184 state |= static_cast<uint32_t>(NodeState::INACTIVE);
185 atomic_set_flag_strong(op.node->m_state, static_cast<NodeState>(state));
186 }
187 });
188}
Memory::PendingQueue< PendingOp, 2048 > m_pending_ops
Operations queued by any thread and applied in arrival order by the processing thread.
Definition RootNode.hpp:207
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:166
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_set_flag_strong(std::atomic< NodeState > &flag, const NodeState &desired)
Atomically sets a node state flag to a specific value.

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

Referenced by enqueue_operation(), postprocess(), and preprocess().

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