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

◆ unregister_node()

void MayaFlux::Nodes::RootNode::unregister_node ( const std::shared_ptr< Node > &  node)

Removes a node from this root node.

Parameters
nodeThe node to unregister

After unregistering, the node will no longer contribute to the root node's output. If called during processing, the operation is deferred until safe.

Definition at line 52 of file RootNode.cpp.

53{
54 if (!node)
55 return;
56
57 uint32_t state = node->m_state.load();
59
60 if (m_is_processing.load(std::memory_order_acquire)) {
61 for (auto& m_pending_op : m_pending_ops) {
62 bool expected = false;
63 if (m_pending_op.active.compare_exchange_strong(
64 expected, true,
65 std::memory_order_acquire,
66 std::memory_order_relaxed)) {
67
68 m_pending_op.node = node;
69 m_pending_count.fetch_add(1, std::memory_order_relaxed);
70 return;
71 }
72 }
73
74 while (m_is_processing.load(std::memory_order_acquire)) {
75 m_is_processing.wait(true, std::memory_order_acquire);
76 }
77 }
78
79 auto it = m_Nodes.begin();
80 while (it != m_Nodes.end()) {
81 if ((*it).get() == node.get()) {
82 it = m_Nodes.erase(it);
83 break;
84 }
85 ++it;
86 }
87 node->reset_processed_state();
88
89 uint32_t flag = node->m_state.load();
90 flag &= ~static_cast<uint32_t>(Utils::NodeState::PENDING_REMOVAL);
91 flag &= ~static_cast<uint32_t>(Utils::NodeState::ACTIVE);
92 flag |= static_cast<uint32_t>(Utils::NodeState::INACTIVE);
93 atomic_set_flag_strong(node->m_state, static_cast<Utils::NodeState>(flag));
94}
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:159
std::atomic< bool > m_is_processing
Flag indicating if the root node is currently processing nodes.
Definition RootNode.hpp:170
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_add_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically adds a flag to a node state.
Definition NodeUtils.cpp:96
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_add_flag(), MayaFlux::Nodes::atomic_set_flag_strong(), MayaFlux::Utils::INACTIVE, m_is_processing, m_Nodes, m_pending_count, m_pending_ops, and MayaFlux::Utils::PENDING_REMOVAL.

Referenced by MayaFlux::Kriya::NodeTimer::cleanup_current_operation(), and terminate_all_nodes().

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