From: Joel Holdsworth Date: Sat, 22 Aug 2015 16:01:49 +0000 (-0600) Subject: Session: Removed signals_mutex(), and made signals() return a copy not a reference X-Git-Tag: pulseview-0.3.0~86 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bf9146988d2298e1750142dccdcf597ef13d6606;p=pulseview.git Session: Removed signals_mutex(), and made signals() return a copy not a reference --- diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index 3cf2ff40..ea5f5fbe 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -75,8 +75,7 @@ Channels::Channels(Session &session, QWidget *parent) : // Collect a set of signals map, shared_ptr > signal_map; - shared_lock lock(session_.signals_mutex()); - const unordered_set< shared_ptr > &sigs(session_.signals()); + const unordered_set< shared_ptr > sigs(session_.signals()); for (const shared_ptr &sig : sigs) signal_map[sig->channel()] = sig; diff --git a/pv/session.cpp b/pv/session.cpp index 0b503e05..45c4e987 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -217,13 +217,9 @@ set< shared_ptr > Session::get_data() const return data; } -boost::shared_mutex& Session::signals_mutex() const -{ - return signals_mutex_; -} - -const unordered_set< shared_ptr >& Session::signals() const +const unordered_set< shared_ptr > Session::signals() const { + shared_lock lock(signals_mutex_); return signals_; } diff --git a/pv/session.hpp b/pv/session.hpp index 689b3f83..0828edbb 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -114,9 +114,7 @@ public: std::set< std::shared_ptr > get_data() const; - boost::shared_mutex& signals_mutex() const; - - const std::unordered_set< std::shared_ptr >& + const std::unordered_set< std::shared_ptr > signals() const; #ifdef ENABLE_DECODE diff --git a/pv/storesession.cpp b/pv/storesession.cpp index 35582b43..da2f963b 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -95,8 +95,7 @@ const QString& StoreSession::error() const bool StoreSession::start() { - shared_lock lock(session_.signals_mutex()); - const unordered_set< shared_ptr > &sigs(session_.signals()); + const unordered_set< shared_ptr > sigs(session_.signals()); // Add enabled channels to the data set set< shared_ptr > data_set; diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index f44d8f94..38cbecb8 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -710,8 +710,7 @@ QComboBox* DecodeTrace::create_channel_selector( { assert(dec); - shared_lock lock(session_.signals_mutex()); - const auto &sigs(session_.signals()); + const auto sigs(session_.signals()); vector< shared_ptr > sig_list(sigs.begin(), sigs.end()); std::sort(sig_list.begin(), sig_list.end(), @@ -749,8 +748,7 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec map > channel_map; - shared_lock lock(session_.signals_mutex()); - const unordered_set< shared_ptr > &sigs(session_.signals()); + const unordered_set< shared_ptr > sigs(session_.signals()); for (const ChannelSelector &s : channel_selectors_) { diff --git a/pv/view/rowitemiterator.hpp b/pv/view/rowitemiterator.hpp index 10de80a0..d75b834d 100644 --- a/pv/view/rowitemiterator.hpp +++ b/pv/view/rowitemiterator.hpp @@ -29,14 +29,6 @@ #include #include -#ifdef _WIN32 -// Windows: Avoid namespace pollution by thread.hpp (which includes windows.h). -#define NOGDI -#define NORESOURCE -#endif -#include -#include - #include namespace pv { @@ -57,12 +49,10 @@ public: public: RowItemIterator(Owner *owner) : - owner_(owner), - lock_(owner->session().signals_mutex()) {} + owner_(owner) {} RowItemIterator(Owner *owner, child_iterator iter) : - owner_(owner), - lock_(owner->session().signals_mutex()) { + owner_(owner) { assert(owner); if (iter != owner->child_items().end()) iter_stack_.push(iter); @@ -70,7 +60,6 @@ public: RowItemIterator(const RowItemIterator &o) : owner_(o.owner_), - lock_(*o.lock_.mutex()), iter_stack_(o.iter_stack_) {} reference operator*() const { @@ -133,7 +122,6 @@ public: private: Owner *owner_; - boost::shared_lock lock_; std::stack iter_stack_; }; diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 6d366e73..d21b75ab 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -396,8 +396,7 @@ void View::set_scale_offset(double scale, const Timestamp& offset) set< shared_ptr > View::get_visible_data() const { - shared_lock lock(session().signals_mutex()); - const unordered_set< shared_ptr > &sigs(session().signals()); + const unordered_set< shared_ptr > sigs(session().signals()); // Make a set of all the visible data objects set< shared_ptr > visible_data; @@ -745,8 +744,7 @@ void View::determine_time_unit() { // Check whether we know the sample rate and hence can use time as the unit if (time_unit_ == util::TimeUnit::Samples) { - shared_lock lock(session().signals_mutex()); - const unordered_set< shared_ptr > &sigs(session().signals()); + const unordered_set< shared_ptr > sigs(session().signals()); // Check all signals but... for (const shared_ptr signal : sigs) { @@ -885,8 +883,7 @@ void View::signals_changed() const set> prev_traces( prev_trace_list.begin(), prev_trace_list.end()); - shared_lock lock(session_.signals_mutex()); - const unordered_set< shared_ptr > &sigs(session_.signals()); + const unordered_set< shared_ptr > sigs(session_.signals()); set< shared_ptr > traces(sigs.begin(), sigs.end());