aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-06-01 23:41:47 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:23 -0800
commit0f8718176993b3460b12720e639b030be9b86943 (patch)
tree81820aad39192e63837c41e557bb6c559136415b /host/lib
parentdc9ca94afaa0a1c049eac934ad1c278deedc6766 (diff)
downloaduhd-0f8718176993b3460b12720e639b030be9b86943.tar.gz
uhd-0f8718176993b3460b12720e639b030be9b86943.tar.bz2
uhd-0f8718176993b3460b12720e639b030be9b86943.zip
rfnoc: graph: Add commit/release API
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/include/uhdlib/rfnoc/graph.hpp15
-rw-r--r--host/lib/rfnoc/graph.cpp23
-rw-r--r--host/lib/rfnoc/rfnoc_graph.cpp10
3 files changed, 44 insertions, 4 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/graph.hpp b/host/lib/include/uhdlib/rfnoc/graph.hpp
index fdb4525d1..49dc62551 100644
--- a/host/lib/include/uhdlib/rfnoc/graph.hpp
+++ b/host/lib/include/uhdlib/rfnoc/graph.hpp
@@ -14,6 +14,7 @@
#include <tuple>
#include <memory>
#include <deque>
+#include <atomic>
namespace uhd { namespace rfnoc { namespace detail {
@@ -44,7 +45,7 @@ public:
//const size_t dst_port);
//
- /*! Run initial checks for graph
+ /*! Commit graph and run initial checks
*
* This method can be called anytime, but it's intended to be called when
* the graph has been committed. It will run checks on the graph and run a
@@ -52,8 +53,14 @@ public:
*
* \throws uhd::resolve_error if the properties fail to resolve.
*/
- void initialize();
+ void commit();
+ /*! Opposite of commit()
+ *
+ * Calling this will disable property propagation until commit() has been
+ * called an equal number of times.
+ */
+ void release();
private:
friend class graph_accessor_t;
@@ -254,6 +261,10 @@ private:
//! Mutex for to avoid the user from sending one message before another
// message is sent
std::recursive_mutex _action_mutex;
+
+ //! This counter gets decremented everytime commit() is called. When zero,
+ // the graph is committed.
+ std::atomic<size_t> _release_count{1};
};
diff --git a/host/lib/rfnoc/graph.cpp b/host/lib/rfnoc/graph.cpp
index d311a00bd..f687e8984 100644
--- a/host/lib/rfnoc/graph.cpp
+++ b/host/lib/rfnoc/graph.cpp
@@ -173,12 +173,21 @@ void graph_t::connect(node_ref_t src_node, node_ref_t dst_node, graph_edge_t edg
}
}
-void graph_t::initialize()
+void graph_t::commit()
{
- UHD_LOG_DEBUG(LOG_ID, "Initializing graph.");
+ if (_release_count) {
+ _release_count--;
+ }
+ UHD_LOG_TRACE(LOG_ID, "graph::commit() => " << _release_count.load());
resolve_all_properties();
}
+void graph_t::release()
+{
+ UHD_LOG_TRACE(LOG_ID, "graph::release() => " << _release_count.load());
+ _release_count++;
+}
+
/******************************************************************************
* Private methods to be called by friends
@@ -188,6 +197,9 @@ void graph_t::resolve_all_properties()
if (boost::num_vertices(_graph) == 0) {
return;
}
+ if (_release_count) {
+ return;
+ }
node_accessor_t node_accessor{};
// First, find the node on which we'll start.
@@ -323,6 +335,13 @@ void graph_t::resolve_all_properties()
void graph_t::enqueue_action(
node_ref_t src_node, res_source_info src_edge, action_info::sptr action)
{
+ if (_release_count) {
+ UHD_LOG_WARNING(LOG_ID,
+ "Action propagation is not enabled, graph is not committed! Will not "
+ "propagate action `"
+ << action->key << "'");
+ return;
+ }
// First, make sure that once we start action handling, no other node from
// a different thread can throw in their own actions
std::lock_guard<std::recursive_mutex> l(_action_mutex);
diff --git a/host/lib/rfnoc/rfnoc_graph.cpp b/host/lib/rfnoc/rfnoc_graph.cpp
index 22c9b7294..94d59da05 100644
--- a/host/lib/rfnoc/rfnoc_graph.cpp
+++ b/host/lib/rfnoc/rfnoc_graph.cpp
@@ -101,6 +101,16 @@ public:
return _mb_controllers.at(mb_index);
}
+ void commit()
+ {
+ _graph->commit();
+ }
+
+ void release()
+ {
+ _graph->release();
+ }
+
private:
/**************************************************************************
* Device Setup