diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-11-17 21:20:55 +0100 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-11-17 21:21:08 +0100 |
commit | 7f25c0120fc7bc6a6eeee87878cf387647d51614 (patch) | |
tree | ab510060a2c5625d00e7f19f4c7d699861b98cea /gnuradio-runtime/lib/pmt/pmt.cc | |
parent | e1acf2d27760d606cc7cba200aa380e885f2ffaf (diff) | |
parent | 1d50d70f0b990b909357a803881955623dea94d8 (diff) |
Merge remote-tracking branch 'upstream/next' into gtk3
Diffstat (limited to 'gnuradio-runtime/lib/pmt/pmt.cc')
-rw-r--r-- | gnuradio-runtime/lib/pmt/pmt.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc index 51fb86e58c..e09452e60e 100644 --- a/gnuradio-runtime/lib/pmt/pmt.cc +++ b/gnuradio-runtime/lib/pmt/pmt.cc @@ -281,7 +281,17 @@ string_to_symbol(const std::string &name) if (name == _symbol(sym)->name()) return sym; // Yes. Return it } - + + // Lock the table on insert for thread safety: + static boost::mutex thread_safety; + boost::mutex::scoped_lock lock(thread_safety); + // Re-do the search in case another thread inserted this symbol into the table + // before we got the lock + for (pmt_t sym = (*get_symbol_hash_table())[hash]; sym; sym = _symbol(sym)->next()){ + if (name == _symbol(sym)->name()) + return sym; // Yes. Return it + } + // Nope. Make a new one. pmt_t sym = pmt_t(new pmt_symbol(name)); _symbol(sym)->set_next((*get_symbol_hash_table())[hash]); |