MayaFlux 0.1.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 185 of file RootNode.cpp.

186{
187
188 for (auto& m_pending_op : m_pending_ops) {
189 if (m_pending_op.active.load(std::memory_order_acquire)) {
190 auto& op = m_pending_op;
191 uint32_t state = op.node->m_state.load();
192
193 if (!(state & Utils::NodeState::ACTIVE)) {
194 m_Nodes.push_back(op.node);
195
196 state &= ~static_cast<uint32_t>(Utils::NodeState::INACTIVE);
197 state |= static_cast<uint32_t>(Utils::NodeState::ACTIVE);
198 atomic_set_flag_strong(op.node->m_state, static_cast<Utils::NodeState>(state));
199 } else if (state & Utils::NodeState::PENDING_REMOVAL) {
200 auto it = m_Nodes.begin();
201 while (it != m_Nodes.end()) {
202 if ((*it).get() == op.node.get()) {
203 it = m_Nodes.erase(it);
204 break;
205 }
206 ++it;
207 }
208 op.node->reset_processed_state();
209
210 state &= ~static_cast<uint32_t>(Utils::NodeState::PENDING_REMOVAL);
211 state &= ~static_cast<uint32_t>(Utils::NodeState::ACTIVE);
212 state |= static_cast<uint32_t>(Utils::NodeState::INACTIVE);
213 atomic_set_flag_strong(op.node->m_state, static_cast<Utils::NodeState>(state));
214 }
215
216 op.node.reset();
217 op.active.store(false, std::memory_order_release);
218 m_pending_count.fetch_sub(1, std::memory_order_relaxed);
219 }
220 }
221}
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:151
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:191
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 preprocess().

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