MayaFlux 0.2.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 198 of file RootNode.cpp.

199{
200
201 for (auto& m_pending_op : m_pending_ops) {
202 if (m_pending_op.active.load(std::memory_order_acquire)) {
203 auto& op = m_pending_op;
204 uint32_t state = op.node->m_state.load();
205
206 if (!(state & Utils::NodeState::ACTIVE)) {
207 m_Nodes.push_back(op.node);
208
209 state &= ~static_cast<uint32_t>(Utils::NodeState::INACTIVE);
210 state |= static_cast<uint32_t>(Utils::NodeState::ACTIVE);
211 atomic_set_flag_strong(op.node->m_state, static_cast<Utils::NodeState>(state));
212 } else if (state & Utils::NodeState::PENDING_REMOVAL) {
213 auto it = m_Nodes.begin();
214 while (it != m_Nodes.end()) {
215 if ((*it).get() == op.node.get()) {
216 it = m_Nodes.erase(it);
217 break;
218 }
219 ++it;
220 }
221 op.node->reset_processed_state();
222
223 state &= ~static_cast<uint32_t>(Utils::NodeState::PENDING_REMOVAL);
224 state &= ~static_cast<uint32_t>(Utils::NodeState::ACTIVE);
225 state |= static_cast<uint32_t>(Utils::NodeState::INACTIVE);
226 atomic_set_flag_strong(op.node->m_state, static_cast<Utils::NodeState>(state));
227 }
228
229 op.node.reset();
230 op.active.store(false, std::memory_order_release);
231 m_pending_count.fetch_sub(1, std::memory_order_relaxed);
232 }
233 }
234}
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:207
void atomic_set_flag_strong(std::atomic< Utils::NodeState > &flag, const Utils::NodeState &desired)
Atomically sets a node state flag to a specific value.
Definition NodeUtils.cpp:90
@ PENDING_REMOVAL
Node is marked for removal.
Definition Utils.hpp:31
@ 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_set_flag_strong(), MayaFlux::Utils::INACTIVE, m_Nodes, m_pending_count, m_pending_ops, and MayaFlux::Utils::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: