From 83abb81e61beec213f9f83843d6fab637a578f4a Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 23 Jul 2019 10:13:38 -0700 Subject: rfnoc: actions: Allow sending actions to self Sending actions to self is useful because calling post_action() from within an action handler will not actually trigger the action. Instead, it will defer delivery of the action. Allowing sending actions to self will allow to add another action, in deterministic order, and the execution of another action handler. --- host/lib/rfnoc/graph.cpp | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'host/lib/rfnoc/graph.cpp') diff --git a/host/lib/rfnoc/graph.cpp b/host/lib/rfnoc/graph.cpp index 174d72389..ff5fde1e9 100644 --- a/host/lib/rfnoc/graph.cpp +++ b/host/lib/rfnoc/graph.cpp @@ -390,29 +390,36 @@ void graph_t::enqueue_action( _action_queue.pop_front(); // Find the node that is supposed to receive this action, and if we find - // something, then send the action - auto recipient_info = - _find_neighbour(_node_map.at(action_src_node), action_src_port); - if (recipient_info.first == nullptr) { - UHD_LOG_WARNING(LOG_ID, - "Cannot forward action " - << action->key << " from " << src_node->get_unique_id() - << ":" << src_edge.to_string() << ", no neighbour found!"); + // something, then send the action. If the source port's type is USER, + // that means the action is meant for us. + node_ref_t recipient_node; + res_source_info recipient_port(action_src_port); + + if (action_src_port.type == res_source_info::USER) { + recipient_node = action_src_node; + recipient_port = action_src_port; } else { - node_ref_t recipient_node = recipient_info.first; - res_source_info recipient_port = { - res_source_info::invert_edge(action_src_port.type), + auto recipient_info = + _find_neighbour(_node_map.at(action_src_node), action_src_port); + recipient_node = recipient_info.first; + if (recipient_node == nullptr) { + UHD_LOG_WARNING(LOG_ID, + "Cannot forward action " + << action->key << " from " << src_node->get_unique_id() << ":" + << src_edge.to_string() << ", no neighbour found!"); + continue; + } + recipient_port = {res_source_info::invert_edge(action_src_port.type), action_src_port.type == res_source_info::INPUT_EDGE - ? recipient_info.second.dst_port - : recipient_info.second.src_port}; - // The following call can cause other nodes to add more actions to - // the end of _action_queue! - UHD_LOG_TRACE(LOG_ID, - "Now delivering action " << next_action_sptr->key << "#" - << next_action_sptr->id); - node_accessor_t{}.send_action( - recipient_node, recipient_port, next_action_sptr); + ? recipient_info.second.src_port + : recipient_info.second.dst_port}; } + // The following call can cause other nodes to add more actions to + // the end of _action_queue! + UHD_LOG_TRACE(LOG_ID, + "Now delivering action " << next_action_sptr->key << "#" + << next_action_sptr->id); + node_accessor_t{}.send_action(recipient_node, recipient_port, next_action_sptr); } UHD_LOG_TRACE(LOG_ID, "Delivered all actions, terminating action handling."); -- cgit v1.2.3