MayaFlux 0.3.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 201 of file RootNode.cpp.

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