aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-06-07 21:37:15 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:27 -0800
commit6bd43946a71173cbf0f1d318843ba34d6849dc30 (patch)
tree35e0b46fc8e399718d6adafcda0929c86e0035ad /host/include
parent491a74269e7d7d7589119c22f229c994d8a2c3f8 (diff)
downloaduhd-6bd43946a71173cbf0f1d318843ba34d6849dc30.tar.gz
uhd-6bd43946a71173cbf0f1d318843ba34d6849dc30.tar.bz2
uhd-6bd43946a71173cbf0f1d318843ba34d6849dc30.zip
rfnoc: Add shutdown feature to blocks
On destruction, the rfnoc_graph will call shutdown() on all blocks. This allows a safe de-initialization of blocks independent of the lifetime of the noc_block_base::sptr. Also adds the shutdown feature to null_block_control.
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/rfnoc/noc_block_base.hpp29
-rw-r--r--host/include/uhd/rfnoc/node.hpp7
2 files changed, 36 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/noc_block_base.hpp b/host/include/uhd/rfnoc/noc_block_base.hpp
index e951ffc72..45a1f5738 100644
--- a/host/include/uhd/rfnoc/noc_block_base.hpp
+++ b/host/include/uhd/rfnoc/noc_block_base.hpp
@@ -160,6 +160,25 @@ protected:
*/
std::shared_ptr<mb_controller> get_mb_controller();
+ /*! Safely de-initialize the block
+ *
+ * This function is called by the framework when the RFNoC session is about
+ * to finish to allow blocks to safely perform actions to shut down a block.
+ * For example, if your block is producing samples, like a radio or signal
+ * generator, this is a good place to issue a "stop" command.
+ *
+ * After this function is called, register access is no more possible. So
+ * make sure not to interact with regs() after this was called. Future
+ * access to regs() won't throw, but will print error messages and do
+ * nothing.
+ *
+ * The rationale for having this separate from the destructor is because
+ * rfnoc_graph allows exporting references to blocks, and this function
+ * ensures that blocks are safely shut down when the rest of the device
+ * control goes away.
+ */
+ virtual void deinit();
+
private:
/*! Update the tick rate of this block
*
@@ -168,6 +187,16 @@ private:
*/
void _set_tick_rate(const double tick_rate);
+ /*! Perform a shutdown sequence.
+ *
+ * - Call deinit()
+ * - Invalidate regs()
+ */
+ void shutdown();
+
+ /**************************************************************************
+ * Attributes
+ **************************************************************************/
//! This block's Noc-ID
noc_id_t _noc_id;
diff --git a/host/include/uhd/rfnoc/node.hpp b/host/include/uhd/rfnoc/node.hpp
index f9a1272e1..04b3d863f 100644
--- a/host/include/uhd/rfnoc/node.hpp
+++ b/host/include/uhd/rfnoc/node.hpp
@@ -350,6 +350,13 @@ protected:
virtual bool check_topology(const std::vector<size_t>& connected_inputs,
const std::vector<size_t>& connected_outputs);
+ /*! Perform a shutdown sequence
+ *
+ * This is mostly relevant for noc_block_base implementations. See also
+ * noc_block_base::shutdown().
+ */
+ virtual void shutdown();
+
/**************************************************************************
* Attributes
*************************************************************************/