36 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
45 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
56 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
58 return (active_mask & channel_bit) != 0;
65 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
67 uint32_t new_pending = old_pending | channel_bit;
70 if ((new_pending & active_channels) == active_channels && active_channels != 0) {
71 uint32_t expected = new_pending;
86 if (active_mask == 0) {
98 uint64_t expected = 0;
100 expected, context_id,
101 std::memory_order_acq_rel,
102 std::memory_order_acquire);
112 uint64_t expected = context_id;
115 std::memory_order_release,
116 std::memory_order_relaxed);
137 auto state =
m_state.load(std::memory_order_acquire);
143 bool expected =
false;
145 std::memory_order_acq_rel)) {
156 uint32_t buffer_count =
m_buffer_count.load(std::memory_order_acquire);
158 if (reset_count + 1 == buffer_count || buffer_count <= 1) {
bool try_claim_snapshot_context(uint64_t context_id)
Attempt to claim snapshot context for this processing cycle.
std::atomic< uint32_t > m_active_channels_mask
Bitmask tracking which channels are currently using this node.
bool has_active_snapshot() const
Check if node is currently being snapshotted by any context.
void add_buffer_reference()
Increments the buffer reference count This method is called when a new buffer starts using this node ...
virtual void on_tick_if(const NodeCondition &condition, const NodeHook &callback)
Registers a conditional callback.
bool is_in_snapshot_context(uint64_t context_id) const
Check if currently in a snapshot context.
void request_buffer_reset()
Requests a reset of the buffer state.
void remove_buffer_reference()
Decrements the buffer reference count This method is called when a buffer stops using this node to en...
std::atomic< uint32_t > m_pending_reset_mask
Bitmask tracking which channels have requested a reset.
std::atomic< bool > m_buffer_processed
Flag indicating whether the buffer has been processed This atomic flag is set when the buffer has bee...
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
std::atomic< uint64_t > m_snapshot_context_id
Unique identifier for the current snapshot context.
virtual void reset_processed_state()
Resets the processed state of the node and any attached input nodes.
std::atomic< uint32_t > m_buffer_reset_count
Counter tracking how many buffers have requested a reset.
bool is_used_by_channel(uint32_t channel_id) const
Checks if the node is currently used by a specific channel.
void unregister_channel_usage(uint32_t channel_id)
Removes the specified channel from the usage tracking.
virtual void reset_processed_state_internal()
Resets the processed state of the node directly.
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
std::atomic< uint32_t > m_buffer_count
Counter tracking how many buffers are using this node This counter is incremented when a buffer start...
virtual void remove_all_hooks()
Removes all registered callbacks.
std::atomic< Utils::NodeState > m_state
Atomic state flag tracking the node's processing status.
virtual bool remove_hook(const NodeHook &callback)
Removes a previously registered callback.
void register_channel_usage(uint32_t channel_id)
Mark the specificed channel as a processor/user.
void request_reset_from_channel(uint32_t channel_id)
Requests a reset of the processed state from a specific channel.
virtual bool remove_conditional_hook(const NodeCondition &callback)
Removes a previously registered conditional callback.
std::vector< float > m_gpu_data_buffer
GPU data buffer for context objects.
std::span< const float > get_gpu_data_buffer() const
Provides access to the GPU data buffer.
bool mark_buffer_processed()
Marks the node as having been processed by a buffer.
virtual void on_tick(const NodeHook &callback)
Registers a callback to be called on each tick.
void release_snapshot_context(uint64_t context_id)
Release snapshot context.
std::function< void(NodeContext &)> NodeHook
Callback function type for node processing events.
bool safe_remove_conditional_callback(std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeCondition &callback)
Safely removes all conditional callbacks with a specific condition.
bool safe_add_callback(std::vector< NodeHook > &callbacks, const NodeHook &callback)
Safely adds a callback to a collection if it doesn't already exist.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
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_remove_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically removes a flag from a node state.
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.
@ INACTIVE
Engine is not processing this node.
@ PROCESSED
Node has been processed this cycle.