aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc/legacy_compat.cpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2016-09-02 11:31:58 -0700
committerMartin Braun <martin.braun@ettus.com>2016-09-02 11:31:58 -0700
commit94385e3e953c380227796ae9ae647ff8c4bd9497 (patch)
tree296e2ee10d0e8a5e8a368a456815959c39f483f1 /host/lib/rfnoc/legacy_compat.cpp
parent3e3524294629f3ad3c1ca0c0011aeadceab90120 (diff)
parent670eeda6e4c9ff2ab81f4e387bce49ea4dc79dcc (diff)
downloaduhd-94385e3e953c380227796ae9ae647ff8c4bd9497.tar.gz
uhd-94385e3e953c380227796ae9ae647ff8c4bd9497.tar.bz2
uhd-94385e3e953c380227796ae9ae647ff8c4bd9497.zip
Merge branch 'maint'
Diffstat (limited to 'host/lib/rfnoc/legacy_compat.cpp')
-rw-r--r--host/lib/rfnoc/legacy_compat.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/host/lib/rfnoc/legacy_compat.cpp b/host/lib/rfnoc/legacy_compat.cpp
index 843cdea34..2c8e10c4a 100644
--- a/host/lib/rfnoc/legacy_compat.cpp
+++ b/host/lib/rfnoc/legacy_compat.cpp
@@ -38,7 +38,7 @@ using uhd::usrp::subdev_spec_pair_t;
using uhd::stream_cmd_t;
/************************************************************************
- * Constants
+ * Constants and globals
***********************************************************************/
static const std::string RADIO_BLOCK_NAME = "Radio";
static const std::string DFIFO_BLOCK_NAME = "DmaFIFO";
@@ -47,6 +47,7 @@ static const std::string DUC_BLOCK_NAME = "DUC";
static const size_t MAX_BYTES_PER_HEADER =
uhd::transport::vrt::chdr::max_if_hdr_words64 * sizeof(uint64_t);
static const size_t BYTES_PER_SAMPLE = 4; // We currently only support sc16
+static boost::mutex _make_mutex;
/************************************************************************
* Static helpers
@@ -700,15 +701,13 @@ legacy_compat::sptr legacy_compat::make(
uhd::device3::sptr device,
const uhd::device_addr_t &args
) {
+ boost::lock_guard<boost::mutex> lock(_make_mutex);
UHD_ASSERT_THROW(bool(device));
static std::map<void *, boost::weak_ptr<legacy_compat> > legacy_cache;
- if (legacy_cache.count(device.get())) {
+ if (legacy_cache.count(device.get()) and not legacy_cache.at(device.get()).expired()) {
legacy_compat::sptr legacy_compat_copy = legacy_cache.at(device.get()).lock();
- if (not bool(legacy_compat_copy)) {
- throw uhd::runtime_error("Reference to existing legacy compat object expired prematurely!");
- }
-
+ UHD_ASSERT_THROW(bool(legacy_compat_copy));
UHD_LEGACY_LOG() << "[legacy_compat] Using existing legacy compat object for this device." << std::endl;
return legacy_compat_copy;
}