From 4ab72eb9991d503d8cd329b31572d966ef0e1ae8 Mon Sep 17 00:00:00 2001 From: Ashish Chaudhari Date: Tue, 4 Apr 2017 19:21:31 -0700 Subject: device3: Fixed potential concurreny issues - Protected block_ctrl vector with a mutex - Note: const block accessors are not thread safe - Removed sid_framer from base device3 class - Made x300,e300 sid_framers atomic --- host/include/uhd/device3.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'host/include') diff --git a/host/include/uhd/device3.hpp b/host/include/uhd/device3.hpp index da23bb263..a2e530321 100644 --- a/host/include/uhd/device3.hpp +++ b/host/include/uhd/device3.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace uhd { @@ -53,12 +54,14 @@ class UHD_API device3 : public uhd::device { * * \param block_id Canonical block name (e.g. "0/FFT_1"). * \return true if a block with the specified id exists + * \note this access is not thread safe if peformed during block enumeration */ bool has_block(const rfnoc::block_id_t &block_id) const; /*! Same as has_block(), but with a type check. * * \return true if a block of type T with the specified id exists + * \note this access is not thread safe if peformed during block enumeration */ template bool has_block(const rfnoc::block_id_t &block_id) const @@ -76,6 +79,7 @@ class UHD_API device3 : public uhd::device { * on this device), it will throw a uhd::lookup_error. * * \param block_id Canonical block name (e.g. "0/FFT_1"). + * \note this access is not thread safe if peformed during block enumeration */ rfnoc::block_ctrl_base::sptr get_block_ctrl(const rfnoc::block_id_t &block_id) const; @@ -91,6 +95,7 @@ class UHD_API device3 : public uhd::device { * uhd::rfnoc::my_block_ctrl::sptr block_controller = get_block_ctrl("0/MyBlock_0"); * block_controller->my_own_block_method(); * \endcode + * \note this access is not thread safe if peformed during block enumeration */ template boost::shared_ptr get_block_ctrl(const rfnoc::block_id_t &block_id) const @@ -115,6 +120,7 @@ class UHD_API device3 : public uhd::device { * // Assume DEV is a device3::sptr * null_block_ctrl::sptr null_block = DEV->find_blocks("NullSrcSink"); * \endcode + * \note this access is not thread safe if peformed during block enumeration */ std::vector find_blocks(const std::string &block_id_hint) const; @@ -138,6 +144,8 @@ class UHD_API device3 : public uhd::device { // It is the responsibility of the deriving class to make // sure this gets correctly populated. std::vector< rfnoc::block_ctrl_base::sptr > _rfnoc_block_ctrl; + //! Mutex to protect access to members + boost::mutex _block_ctrl_mutex; }; } //namespace uhd -- cgit v1.2.3