MayaFlux 0.5.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 200 of file RootNode.cpp.

201{
202 for (auto& pending_op : m_pending_ops) {
203 if (!pending_op.active.load(std::memory_order_acquire))
204 continue;
205
206 auto& op = pending_op;
207
208 if (op.is_addition) {
209 if (m_Nodes.end() == std::ranges::find(m_Nodes, op.node)) {
210 m_Nodes.push_back(op.node);
211 uint32_t state = op.node->m_state.load();
212 state &= ~static_cast<uint32_t>(NodeState::INACTIVE);
213 state |= static_cast<uint32_t>(NodeState::ACTIVE);
214 atomic_set_flag_strong(op.node->m_state, static_cast<NodeState>(state));
215 }
216 } else {
217 auto it = m_Nodes.begin();
218 while (it != m_Nodes.end()) {
219 if ((*it).get() == op.node.get()) {
220 it = m_Nodes.erase(it);
221 break;
222 }
223 ++it;
224 }
225 op.node->reset_processed_state();
226 uint32_t state = op.node->m_state.load();
227 state &= ~static_cast<uint32_t>(NodeState::PENDING_REMOVAL);
228 state &= ~static_cast<uint32_t>(NodeState::ACTIVE);
229 state |= static_cast<uint32_t>(NodeState::INACTIVE);
230 atomic_set_flag_strong(op.node->m_state, static_cast<NodeState>(state));
231 }
232
233 op.node.reset();
234 op.active.store(false, std::memory_order_release);
235 m_pending_count.fetch_sub(1, std::memory_order_relaxed);
236 }
237}
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:165
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:215
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.
Definition NodeUtils.cpp:54

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

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

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