From ec991efc06676521267aa05259df59898c758338 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 1 Aug 2019 17:45:29 -0700 Subject: rfnoc: graph: Lock release/commit state Property propagation and action handling depend on the release state, but they are lengthy operations. It is therefore imperative to not change the release/commit state during those methods. This commit changes the following: - Change the release state counter from an atomic to a non-atomic variable - Instead, use a mutex to lock the release state counter, and use the same mutex for locking access to the property propagation and action handling The rfnoc_graph now tries to release the graph before shutting down blocks to make sure they don't get destroyed while those algorithms are still running. --- host/lib/include/uhdlib/rfnoc/graph.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'host/lib/include/uhdlib/rfnoc/graph.hpp') diff --git a/host/lib/include/uhdlib/rfnoc/graph.hpp b/host/lib/include/uhdlib/rfnoc/graph.hpp index 87977a1dc..5b735b624 100644 --- a/host/lib/include/uhdlib/rfnoc/graph.hpp +++ b/host/lib/include/uhdlib/rfnoc/graph.hpp @@ -7,14 +7,14 @@ #ifndef INCLUDED_LIBUHD_GRAPH_HPP #define INCLUDED_LIBUHD_GRAPH_HPP -#include #include +#include #include #include -#include -#include #include -#include +#include +#include +#include namespace uhd { namespace rfnoc { namespace detail { @@ -273,9 +273,12 @@ private: // message is sent std::recursive_mutex _action_mutex; + //! Changes to the release/commit state of the graph are locked with this mutex + std::recursive_mutex _release_mutex; + //! This counter gets decremented everytime commit() is called. When zero, // the graph is committed. - std::atomic _release_count{1}; + size_t _release_count{1}; }; -- cgit v1.2.3