11 return std::ranges::any_of(callbacks,
13 return hook.target_type() == callback.target_type();
19 return std::ranges::any_of(callbacks,
20 [&callback](
const std::pair<NodeHook, NodeCondition>& pair) {
21 return pair.second.target_type() == callback.target_type();
27 return std::ranges::any_of(callbacks,
28 [&callback, &condition](
const std::pair<NodeHook, NodeCondition>& pair) {
29 return pair.first.target_type() == callback.target_type() && pair.second.target_type() == condition.target_type();
36 callbacks.push_back(callback);
45 callbacks.emplace_back(callback, condition);
54 auto it = callbacks.begin();
56 while (it != callbacks.end()) {
57 if (it->target_type() == callback.target_type()) {
58 it = callbacks.erase(it);
71 auto it = callbacks.begin();
73 while (it != callbacks.end()) {
74 if (it->second.target_type() == callback.target_type()) {
75 it = callbacks.erase(it);
87 flag.compare_exchange_strong(expected, desired);
92 auto expected = flag.load();
93 flag.compare_exchange_strong(expected, desired);
98 auto current = state.load();
102 }
while (!state.compare_exchange_weak(current, desired,
103 std::memory_order_acq_rel,
104 std::memory_order_acquire));
109 auto current = state.load();
113 }
while (!state.compare_exchange_weak(current, desired,
114 std::memory_order_acq_rel,
115 std::memory_order_acquire));
120 flag.compare_exchange_weak(expected, desired);
125 count.fetch_add(amount, std::memory_order_relaxed);
130 count.fetch_sub(amount, std::memory_order_relaxed);
135 if (node && node->m_modulator_count.load(std::memory_order_relaxed) == 0) {
136 node->reset_processed_state();
140std::vector<uint32_t>
get_active_channels(
const std::shared_ptr<Nodes::Node>& node, uint32_t fallback_channel)
142 uint32_t channel_mask = node ? node->get_channel_mask().load() : 0;
148 std::vector<uint32_t> channels;
150 if (channel_mask == 0) {
151 channels.push_back(fallback_channel);
154 if (channel_mask & (1ULL << channel)) {
155 channels.push_back(channel);
NodeConfig & get_node_config()
std::function< void(NodeContext &)> NodeHook
Callback function type for node processing events.
bool callback_pair_exists(const std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeHook &callback, const NodeCondition &condition)
Checks if a specific callback and condition pair already exists.
bool callback_exists(const std::vector< NodeHook > &callbacks, const NodeHook &callback)
Checks if a callback function already exists in a collection.
bool safe_remove_conditional_callback(std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeCondition &callback)
Safely removes all conditional callbacks with a specific condition.
void atomic_add_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically adds a flag to a node state.
bool safe_add_callback(std::vector< NodeHook > &callbacks, const NodeHook &callback)
Safely adds a callback to a collection if it doesn't already exist.
void atomic_set_strong(std::atomic< Utils::NodeState > &flag, Utils::NodeState &expected, const Utils::NodeState &desired)
Atomically sets a node state flag with strong memory ordering.
std::vector< uint32_t > get_active_channels(const std::shared_ptr< Nodes::Node > &node, uint32_t fallback_channel)
Extracts active channel list from a node's channel mask.
bool conditional_callback_exists(const std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeCondition &callback)
Checks if a condition function already exists in a collection of conditional callbacks.
void try_reset_processed_state(std::shared_ptr< Node > node)
Attempts to reset the processed state of a node.
void atomic_inc_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically increments the modulator count by a specified amount.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
void atomic_dec_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically decrements the modulator count by a specified amount.
bool safe_add_conditional_callback(std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeHook &callback, const NodeCondition &condition)
Safely adds a conditional callback if it doesn't already exist.
void atomic_set_flag_strong(std::atomic< Utils::NodeState > &flag, const Utils::NodeState &desired)
Atomically sets a node state flag to a specific value.
void atomic_remove_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically removes a flag from a node state.
void atomic_set_flag_weak(std::atomic< Utils::NodeState > &flag, Utils::NodeState &expected, const Utils::NodeState &desired)
Atomically sets a node state flag with weak memory ordering.
bool safe_remove_callback(std::vector< NodeHook > &callbacks, const NodeHook &callback)
Safely removes a callback from a collection.
Contains the node-based computational processing system components.
uint32_t max_channels
Maximum number of channels supported (uint32_t bits)